Transport-for-the-North / caf.base

Core classes and definitions for CAF family of tools
GNU General Public License v3.0
0 stars 1 forks source link

Pandas Future warning when using zone translation, Pandas version 2.2 #67

Open Kieran-Fishwick-TfN opened 1 week ago

Kieran-Fishwick-TfN commented 1 week ago

zoning.py line: 543 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.

rahimbaig28 commented 5 days ago

Current code (likely triggering the warning)

df[df['column'] == value]['other_column'] = new_value

Recommended solution using .loc[] to avoid chaining

df.loc[df['column'] == value, 'other_column'] = new_value