Skip to content

Fix forecast output assignment and avoid SettingWithCopyWarning#508

Merged
davidusb-geek merged 7 commits into
davidusb-geek:masterfrom
radim2tej:waring
Apr 12, 2025
Merged

Fix forecast output assignment and avoid SettingWithCopyWarning#508
davidusb-geek merged 7 commits into
davidusb-geek:masterfrom
radim2tej:waring

Conversation

@radim2tej
Copy link
Copy Markdown
Contributor

Fix forecast output assignment and avoid SettingWithCopyWarning. Warnings were generated when using the energy price from the CSV file:
/app/src/emhass/forecast.py:1428: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
/app/src/emhass/forecast.py:1500: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy

@sonarqubecloud
Copy link
Copy Markdown

@davidusb-geek
Copy link
Copy Markdown
Owner

Hi, thanks for the fix.
One quick question, why are you updating: cec_inverters.pbz2 and cec_modules.pbz2?

@radim2tej
Copy link
Copy Markdown
Contributor Author

I don't know how that could have happened. I only edited forecast.py. Can you fix it? I'm not very good at it, unfortunately.

@davidusb-geek
Copy link
Copy Markdown
Owner

Ok I got it you were just updating from the master branch

@davidusb-geek davidusb-geek merged commit bdcac6d into davidusb-geek:master Apr 12, 2025
14 checks passed
@purcell-lab
Copy link
Copy Markdown
Contributor

After the upgrade to 0.13.1 I am still seeing this issue:

#515

[2025-04-22 19:45:30 +1000] [23] [INFO] Performing naive MPC optimization
/app/src/emhass/forecast.py:1595: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
/app/src/emhass/forecast.py:1670: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
[2025-04-22 19:45:30 +1000] [23] [INFO] Perform an iteration of a naive MPC controller

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