Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FutureWarning: ChainedAssignmentError: behaviour will change in pandas 3.0! #7

Closed
Typhus14 opened this issue Nov 2, 2024 · 3 comments
Assignees

Comments

@Typhus14
Copy link

Typhus14 commented Nov 2, 2024

Hello,
Eto code use fonctions of Panda that will become obsolete soon. Do you think to correct this ?
Thank you for the work

You are setting values through chained assignment. Currently this works in certain cases, but when using Copy-on-Write (which will become the default behaviour in pandas 3.0) this will never work to update the original DataFrame or Series, because the intermediate object on which we are setting values will behave as a copy.
A typical example is when you are setting values in a column of a DataFrame, like:

df["col"][row_indexer] = value

Use df.loc[row_indexer, "col"] = values instead, to perform the assignment in a single step and ensure this keeps updating the original df.

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy

self.ts_param['e_a'].loc[self.ts_param['e_a'].isnull()] = (self.ts_param['e_min'][self.ts_param['e_a'].isnull()] * self.ts_param.loc[self.ts_param['e_a'].isnull(), 'RH_max']/100 + self.ts_param['e_max'][self.ts_param['e_a'].isnull()] * self.ts_param.loc[self.ts_param['e_a'].isnull(), 'RH_min']/100)/2

@mullenkamp mullenkamp self-assigned this Nov 2, 2024
@mullenkamp
Copy link
Member

Hi @Typhus14 ,

Thank you very much for detailing the issue and how to fix it. As you mentioned, it should be a pretty easy fix. I'll hopefully get to it soon.

@mullenkamp
Copy link
Member

Fixed with #8
Use the new version 1.1.1

@Typhus14
Copy link
Author

Typhus14 commented Nov 6, 2024

Thank you very much for the fix. It work very well.
best regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants