Sage-Bionetworks / synapsePythonClient

Programmatic interface to Synapse services for Python
https://www.synapse.org
Apache License 2.0
65 stars 67 forks source link

`FutureWarning` received when reading in a Synapse table as a data frame #1073

Closed vpchung closed 4 months ago

vpchung commented 4 months ago

Bug Report

Github issues is reserved for bug report. If you have a question, please don't use this form. Instead, please ask your question on the Synapse Help Forum.

Operating system

Mac

Client version

4.1.0

Description of the problem

This is not so much a bug report, but an observation -- I recently upgraded to the latest version of pandas (2.2.1), and I now receive this warning when reading in a table as a data frame, e.g.

>>> table = syn.tableQuery("SELECT * FROM syn52955244").asDataFrame()
...
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.

  df[col].fillna("[]", inplace=True)

I did not encounter this warning on pandas 2.1.1.

Expected behavior

No warning would be given.

Actual behavior

The warning is given.

[!NOTE] FWIW, asDataFrame() still works as expected currently, but it sounds like df[col].fillna("[]", inplace=True) may behave differently once pandas 3.0 is out.

vpchung commented 4 months ago

Moving to Jira - closing this ticket now~