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

Pandas update: Fixed some bugs that caused future warnings in pandas #360

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jerryinyang
Copy link

MAJOR FIXES:
-_plotting\core.py : FutureWarning was raised by some lines of code; attempting to set a value on a copy of a DataFrame or Series through chained assignment using an inplace method.

  • _plotting\core.py and reports.py : Replaced the deprecated pandas frequency labels: M, Q, and A (all depreacted) to ME, QE and YE.

MINOR FIXES:

  • Sorted imports (linted code) in the above mentioned files

Previous (now removed) warning messages from the above

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.


  port["Weekly"].ffill(inplace=True)


FutureWarning: 'M' is deprecated and will be removed in a future version, please use 'ME' instead.
  port["Monthly"] = port["Daily"].resample("M").apply(apply_fnc)



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.


  port["Monthly"].ffill(inplace=True)



FutureWarning: 'Q' is deprecated and will be removed in a future version, please use 'QE' instead.
  port["Quarterly"] = port["Daily"].resample("Q").apply(apply_fnc)



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.


  port["Quarterly"].ffill(inplace=True)



FutureWarning: 'A' is deprecated and will be removed in a future version, please use 'YE' instead.
  port["Yearly"] = port["Daily"].resample("A").apply(apply_fnc)



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.

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

Successfully merging this pull request may close these issues.

1 participant