influxdata / influxdb-client-python

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

fix: Pandas 3.0 warning for inplace method #642

Closed lars20070 closed 7 months ago

lars20070 commented 7 months ago

Related #637

Proposed Changes

Currently, the following warning for inplace methods in the upcoming Pandas 3.0 is triggered.

~/.venv/lib/python3.11/site-packages/influxdb_client/client/write/dataframe_serializer.py:237: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.

The pull request silences the warning.

Checklist

lars20070 commented 7 months ago

Hi @bednar, Pandas is currently in version 2.2 with 3.0 scheduled for April 2024. No, I cannot explain why Pandas triggered the warning. But you might be on the safe side using option 2 and be prepared for the upcoming breaking changes. I can see your #638 changes but still get the warning from this line.

lars20070 commented 7 months ago

@bednar I struggle a bit to understand your setup. I am more familiar with Poetry projects. I would appreciate your input.

bednar commented 7 months ago

@lars20070, please sign the CLA and check the checkbox so we can proceed with merging your PR.

lars20070 commented 7 months ago

Signed. Thanks @bednar.

lars20070 commented 7 months ago

On a totally unrelated note. Any chance of looking into this issue? Apologies for cross-posting.

bednar commented 7 months ago

@lars20070 unfurnetally I don't know anything about vsflux... I am at JetBrains IDEs ;)