Skip to content

Commit

Permalink
fix resampling with DateOffset (#2479)
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisbader authored Jul 30, 2024
1 parent a9c180a commit f3e56ce
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions darts/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -3319,7 +3319,9 @@ def add_holidays(
)
)

def resample(self, freq: str, method: str = "pad", **kwargs) -> Self:
def resample(
self, freq: Union[str, pd.DateOffset], method: str = "pad", **kwargs
) -> Self:
"""
Build a reindexed ``TimeSeries`` with a given frequency.
Provided method is used to fill holes in reindexed TimeSeries, by default 'pad'.
Expand All @@ -3328,7 +3330,7 @@ def resample(self, freq: str, method: str = "pad", **kwargs) -> Self:
----------
freq
The new time difference between two adjacent entries in the returned TimeSeries.
A DateOffset alias is expected.
Expects a `pandas.DateOffset` or `DateOffset` alias.
method:
Method to fill holes in reindexed TimeSeries (note this does not fill NaNs that already were present):
Expand Down Expand Up @@ -3371,6 +3373,8 @@ def resample(self, freq: str, method: str = "pad", **kwargs) -> Self:
TimeSeries
A reindexed TimeSeries with given frequency.
"""
if isinstance(freq, pd.DateOffset):
freq = freq.freqstr

resample = self._xa.resample(
indexer={self._time_dim: freq},
Expand Down

0 comments on commit f3e56ce

Please sign in to comment.