influxdata / influxdb-client-python

InfluxDB 2.0 python client
https://influxdb-client.readthedocs.io/en/stable/
MIT License
706 stars 185 forks source link

Refactor DataFrame Operations to Avoid Chained Assignment and Address FutureWarning in Pandas #637

Closed MattBrth closed 7 months ago

MattBrth commented 7 months ago

Proposal: Refactor DataFrame operations to avoid chained assignment and resolve FutureWarning in pandas, ensuring compatibility with the upcoming changes in pandas 3.0.

Current behavior: Using data_frame[k].replace('', np.nan, inplace=True) triggers a FutureWarning regarding chained assignment, indicating that this approach will not be supported in pandas 3.0.

Desired behavior: Adopt a refactoring approach that aligns with pandas' best practices and future compatibility, such as using data_frame[k] = data_frame[k].replace('', np.nan) or data_frame.replace({k: ''}, np.nan, inplace=True).

Alternatives considered:

  1. Use data_frame[k] = data_frame[k].replace('', np.nan) for direct column operations.
  2. Use data_frame.replace({k: ''}, np.nan, inplace=True) to apply the replacement across the entire DataFrame.

Use case: Ensuring that the DataFrame operations are future-proof and compatible with upcoming versions of pandas is essential for the maintainability and stability of the codebase. This change will prevent potential runtime errors or unexpected behaviors resulting from deprecated practices in pandas.