Open spawn-guy opened 2 weeks ago
df.update
doesn't support CoW
Thanks for the report - can you provide a reproducible example on how CoW is not supported.
@rhshadrach here is some code and log
# select best source: heading
# HeadingTrue > HeadingMagnetic > HeadingAndDeclination (this is also magnetic) > TrackMadeGood
measurements_df["heading"] = measurements_df["gps_course_over_ground"]
# replace if other value is not nan
measurements_df["heading"].update(measurements_df["gps_heading"])
FutureWarning
_task.py:427: 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.
measurements_df["heading"].update(measurements_df["gps_heading"])
Inconsistency with the warning:
df[col] = df[col].update(value)
that actually "returns" somethingThanks @spawn-guy, however your example is not reproducible because you did not provide measurements_df
. Can you provide a reproducible example?
Pandas version checks
main
hereLocation of the documentation
https://pandas.pydata.org/docs/dev/reference/api/pandas.Series.update.html#pandas.Series.update
Documentation problem
df.update
resembles howpython.dict.update
works, butdf.update
doesn't support CoWSuggested fix for documentation
remove FutureWarning for the
df.update
or create a (for example)
df.coalesce
method that will, actually,return
something. this shouldn't brake existing code