From 7d3929d88c3da74bd2b50bc7d7655c4d0d2d8710 Mon Sep 17 00:00:00 2001 From: martin-springer Date: Wed, 11 Sep 2024 12:58:09 -0400 Subject: [PATCH] pd deprecation fixes in filtering.py --- rdtools/filtering.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rdtools/filtering.py b/rdtools/filtering.py index 589a6812..348e0e19 100644 --- a/rdtools/filtering.py +++ b/rdtools/filtering.py @@ -596,7 +596,7 @@ def logic_clip_filter( .drop_duplicates(subset=power_ac.index.name, keep="first") .set_index(power_ac.index.name) ) - freq_string = str(time_series_sampling_frequency) + "T" + freq_string = str(time_series_sampling_frequency) + "min" # Set days with the majority of frozen data to null. daily_std = power_ac.resample("D").std() / power_ac.resample("D").mean() power_ac["daily_std"] = daily_std.reindex(index=power_ac.index, method="ffill") @@ -746,7 +746,7 @@ def _calculate_xgboost_model_features(df, sampling_frequency): ) # Get the max value for the day and see how each value compares df["date"] = list(pd.to_datetime(pd.Series(df.index)).dt.date) - df["daily_max"] = df.groupby(["date"])["scaled_value"].transform(max) + df["daily_max"] = df.groupby(["date"])["scaled_value"].transform("max") # Get percentage of daily max df["percent_daily_max"] = df["scaled_value"] / (df["daily_max"] + 0.00001) # Get the standard deviation, median and mean of the first order @@ -826,7 +826,7 @@ def xgboost_clip_filter(power_ac, mounting_type="fixed"): sampling_frequency = int( (power_ac.index.to_series().diff() / pd.Timedelta("60s")).mode()[0] ) - freq_string = str(sampling_frequency) + "T" + freq_string = str(sampling_frequency) + "min" # Min-max normalize # Resample the series based on the most common sampling frequency power_ac_interpolated = rdtools.normalization.interpolate(power_ac, freq_string) @@ -838,7 +838,7 @@ def xgboost_clip_filter(power_ac, mounting_type="fixed"): # once every five minute, resample at 5-minute intervals before # plugging into the model if sampling_frequency < 5: - power_ac_df = power_ac_df.resample("5T").mean() + power_ac_df = power_ac_df.resample("5min").mean() power_ac_df["sampling_frequency"] = 5 # Add mounting type as a column power_ac_df["mounting_config"] = mounting_type @@ -882,7 +882,7 @@ def xgboost_clip_filter(power_ac, mounting_type="fixed"): # Reindex with the original data index. Re-adjusts to original # data frequency. xgb_predictions = xgb_predictions.reindex(index=power_ac.index, method="ffill") - xgb_predictions = xgb_predictions.fillna(False) + xgb_predictions = xgb_predictions.astype(bool).fillna(False) # Regenerate the features with the original sampling frequency # (pre-resampling or interpolation). power_ac_df = power_ac.to_frame()