From c131e648676b38b94acdf4d5a702152215068a03 Mon Sep 17 00:00:00 2001 From: Johannes Ott Date: Fri, 29 Mar 2024 22:36:39 +0100 Subject: [PATCH] Fix datetime problem at prediction dataframe Signed-off-by: Johannes Ott --- solaredge2mqtt/service/forecast.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/solaredge2mqtt/service/forecast.py b/solaredge2mqtt/service/forecast.py index 08652fc..eab6e96 100644 --- a/solaredge2mqtt/service/forecast.py +++ b/solaredge2mqtt/service/forecast.py @@ -14,8 +14,7 @@ from sklearn.compose import ColumnTransformer from sklearn.ensemble import HistGradientBoostingRegressor from sklearn.inspection import permutation_importance -from sklearn.model_selection import (GridSearchCV, TimeSeriesSplit, - train_test_split) +from sklearn.model_selection import GridSearchCV, TimeSeriesSplit, train_test_split from sklearn.pipeline import Pipeline from solaredge2mqtt.exceptions import InvalidDataException @@ -24,8 +23,7 @@ from solaredge2mqtt.mqtt import MQTTClient from solaredge2mqtt.service.influxdb import InfluxDB, Point from solaredge2mqtt.service.weather import WeatherClient -from solaredge2mqtt.settings import (LOCAL_TZ, ForecastSettings, - LocationSettings) +from solaredge2mqtt.settings import LOCAL_TZ, ForecastSettings, LocationSettings class ForecasterType(EnumModel): @@ -175,6 +173,7 @@ async def forecast_loop(self): ] data = DataFrame(estimation_data_list) + data["time"] = data["time"].astype(f"datetime64[ns, {LOCAL_TZ}]") for typed, forecaster in self.forecasters.items(): predicted_data = await forecaster.predict(data)