From 3c36a844ee47e9131b4000629f6d4971a83b52fa Mon Sep 17 00:00:00 2001 From: Maike Held Date: Tue, 2 Aug 2022 15:36:24 +0200 Subject: [PATCH] Added documentation and NotImplementedError --- edisgo/network/timeseries.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/edisgo/network/timeseries.py b/edisgo/network/timeseries.py index 526d2a4ce..6e689a928 100644 --- a/edisgo/network/timeseries.py +++ b/edisgo/network/timeseries.py @@ -2147,8 +2147,9 @@ def _check_if_components_exist( def resample_timeseries(self, method: str = "ffill", freq: str = "15min"): """ - Returns timeseries resampled from hourly resolution to 15 minute resolution. - #ToDo: Adjust docstring + Returns timeseries resampled to a desired resolution. Both up- and down- + sampling methods are available. + Parameters ---------- method : str, optional @@ -2167,8 +2168,7 @@ def resample_timeseries(self, method: str = "ffill", freq: str = "15min"): https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.interpolate.html freq : str, optional - Frequency that timeseries is resampled to. Can be any frequency up to one - hour. Offset aliases can be found here: + Frequency that timeseries is resampled to. Offset aliases can be found here: https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases 15 minutes is the default. @@ -2179,9 +2179,7 @@ def resample_timeseries(self, method: str = "ffill", freq: str = "15min"): for attr in attrs: df_dict[attr] = getattr(self, attr) if pd.Timedelta(freq) < freq_orig: # up-sampling - new_dates = pd.DatetimeIndex( - [df_dict[attr].index[-1] + freq_orig] # pd.DateOffset(hours=1) - ) + new_dates = pd.DatetimeIndex([df_dict[attr].index[-1] + freq_orig]) else: # down-sampling new_dates = pd.DatetimeIndex([df_dict[attr].index[-1]]) df_dict[attr] = ( @@ -2221,8 +2219,10 @@ def resample_timeseries(self, method: str = "ffill", freq: str = "15min"): setattr( self, attr, df_dict[attr].resample(freq, closed="left").bfill() ) - else: # ToDo: Logger Warning: method not implemented - print(" ") + else: + raise NotImplementedError( + 'Resampling method "{}" is not implemented.'.format(method) + ) else: # down-sampling for attr in attrs: setattr(