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

Support multiple days forecasting with CSV data. #485

Merged
merged 4 commits into from
Mar 10, 2025

Conversation

nielskool
Copy link
Contributor

With CSV data as input for prices, the forecasting broke if it was more than 1 day.

With the updated code, only csv data for the day that is being forcasted is taken.

File "/app/src/emhass/forecast.py", line 849, in get_forecast_out_from_csv_or_list forecast_out = pd.DataFrame( ^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/pandas/core/frame.py", line 827, in __init__ mgr = ndarray_to_mgr( ^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/pandas/core/internals/construction.py", line 336, in ndarray_to_mgr _check_values_indices_shape_match(values, index, columns) File "/app/.venv/lib/python3.12/site-packages/pandas/core/internals/construction.py", line 420, in _check_values_indices_shape_match raise ValueError(f"Shape of passed values is {passed}, indices imply {implied}") ValueError: Shape of passed values is (52, 1), indices imply (26, 1)

@davidusb-geek
Copy link
Owner

Hi thanks for contributing.
What if we want to forecast several days, is this compatible?

@nielskool
Copy link
Contributor Author

nielskool commented Mar 10, 2025

I tested with 1,2 and 3 days forecasting. that worked now. Earlier only 1 day worked.
So it does forecasting per day on line 809 and now per day it only takes the relevant part of the csv data.
if you forecast multiple days it will take for each day the relevant part of the csv.

@nielskool
Copy link
Contributor Author

i checked the failingtest. I have almost an update ready that makes the first column of the csv actually used as a date column, current code ignores the date in the first column in the csv.

The test now failes, because the provided sample csv does not match.
So the update will have 2 things, make the first column the date index column(if available)
and update the dates in the provided csv to match the requested forcasting

… pandas if and only if it can be converted to a datetime.
@nielskool
Copy link
Contributor Author

dont accept this request yet. i am actually doing some extra tests still. although the included tests suceeed, i want to verify it myself still

@nielskool
Copy link
Contributor Author

Made one more change to make sure that the time format is actually taking into account the +01:00 part.
tested on my side. For me this works.

@davidusb-geek
Copy link
Owner

Thanks for contributing to this, merging

@davidusb-geek davidusb-geek merged commit cb2a93a into davidusb-geek:master Mar 10, 2025
14 checks passed
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.

2 participants