From 0ccf134c8104c417fe83d238ba64b64c3e419ff7 Mon Sep 17 00:00:00 2001 From: Jonita Ruiter <148341618+JonitaRuiter@users.noreply.github.com> Date: Tue, 20 Feb 2024 13:35:23 +0100 Subject: [PATCH] update on both .shift() and [index].iloc[column] deprecation warning (#510) * update on both .shift() and [index].iloc[column] deprecation warning of pandas Signed-off-by: Jonita Ruiter * Format Python code with Black Signed-off-by: black * trying to fix black format fail Signed-off-by: Jonita Ruiter * Format Python code with Black Signed-off-by: black * trying to fix black format fail2 Signed-off-by: Jonita Ruiter --------- Signed-off-by: Jonita Ruiter Signed-off-by: black Co-authored-by: black --- openstef/feature_engineering/lag_features.py | 2 +- openstef/model/standard_deviation_generator.py | 5 +++-- test/unit/pipeline/test_create_basecase.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/openstef/feature_engineering/lag_features.py b/openstef/feature_engineering/lag_features.py index 72b2bdf12..e84ebcdeb 100644 --- a/openstef/feature_engineering/lag_features.py +++ b/openstef/feature_engineering/lag_features.py @@ -43,7 +43,7 @@ def generate_lag_feature_functions( for minutes in lag_times_minutes: # Add intraday-lag functions (lags in minutes) def func(x, shift=minutes): - return x.shift(freq="T", periods=1 * shift) + return x.shift(freq="min", periods=1 * shift) new = {"T-" + str(int(minutes)) + "min": func} lag_functions.update(new) diff --git a/openstef/model/standard_deviation_generator.py b/openstef/model/standard_deviation_generator.py index 60c28b3b2..f268b4b0e 100644 --- a/openstef/model/standard_deviation_generator.py +++ b/openstef/model/standard_deviation_generator.py @@ -72,8 +72,9 @@ def _calculate_standard_deviation( # For the time starts with 00, 01, 02, etc. TODO (MAKE MORE ELEGANT SOLUTION THAN A LOOP) for hour in range(24): hour_error = error[error.index == hour] - result["stdev"].iloc[hour] = np.std(hour_error) - result["hour"].iloc[hour] = hour + + result.loc[hour, "stdev"] = np.std(hour_error) + result.loc[hour, "hour"] = hour result = result.astype("float") diff --git a/test/unit/pipeline/test_create_basecase.py b/test/unit/pipeline/test_create_basecase.py index 610e95407..fdd3b0999 100644 --- a/test/unit/pipeline/test_create_basecase.py +++ b/test/unit/pipeline/test_create_basecase.py @@ -28,7 +28,7 @@ def setUp(self) -> None: - (forecast_input.index.max() - timedelta(days=7)) ).total_seconds() forecast_input = forecast_input.shift( - freq="T", periods=int(int(offset_seconds / 60.0 / 15.0) * 15) + freq="min", periods=int(int(offset_seconds / 60.0 / 15.0) * 15) ) self.forecast_input = forecast_input