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

Fix FutureWarnings #57

Merged
merged 2 commits into from
Jun 26, 2024
Merged

Fix FutureWarnings #57

merged 2 commits into from
Jun 26, 2024

Conversation

maurerle
Copy link
Contributor

To Reproduce
The following snippet produces warnings using python 3.11 and pandas 2.2.1

from demandlib.bdew import ElecSlp
e_slp = ElecSlp(2019)

demandlib had some pandas warnings:

  • FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version
  • FutureWarning: Setting an item of incompatible dtype is deprecated and will raise in a future error of pandas
  • FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method

These are fixed through this commit.

demandlib had some pandas warnings:
FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version
FutureWarning: Setting an item of incompatible dtype is deprecated and will raise in a future error of pandas
FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method

These are fixed through this commit
Comment on lines 124 to 125
tmp_df["hour_of_day"] = tmp_df.index.hour.astype(float)
tmp_df["minute_of_hour"] = tmp_df.index.minute.astype(float)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it make sense to preserve the integers, here?

Suggested change
tmp_df["hour_of_day"] = tmp_df.index.hour.astype(float)
tmp_df["minute_of_hour"] = tmp_df.index.minute.astype(float)
tmp_df["hour_of_day"] = tmp_df.index.hour.astype(int)
tmp_df["minute_of_hour"] = tmp_df.index.minute.astype(int)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tmp_df.index.hour is already int - we need to adjust this in L117 and L119 and remove it in L124 and L125.
Will do

@p-snft
Copy link
Member

p-snft commented Jun 25, 2024

Hi @maurerle, thanks for your fixes (and sorry for letting this uncommented for such a long time). I just realised that demandlib needs some love (to have a maintenance release) and so I am very happy that you cared for some of the changes needed to maintain compatibility.

If you like, don't forget to add your name to the list of authors.

@pep8speaks
Copy link

Hello @maurerle! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 208:1: W293 blank line contains whitespace
Line 208:1: W391 blank line at end of file

@p-snft p-snft merged commit 898a10d into oemof:dev Jun 26, 2024
6 of 9 checks passed
@maurerle maurerle deleted the fix_future_warnings branch June 26, 2024 08:00
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.

3 participants