Open vfilter opened 2 years ago
Hi @vfilter and thanks for writing. Our resample()
method works different to pandas resample.
From our docs:
Resample creates a reindexed time series with a given frequency.
The method is used to fill holes in reindexed TimeSeries, by default 'pad'.
It is true that it would be nice to extend our method to be more like pandas` resample. I will add this to our backlog.
You can achieve the desired results with:
TimeSeries.from_dataframe(series.pd_dataframe().resample('Y').sum())
Pandas returns a *IndexResampler
. We could either extend resample()
or implement a new method. We could add support for IndexResampler
to our stats methods like sum()
which would convert it back into a TimeSeries object.
Following this issue with interest! Aggregate resample is critical to many of our workflows. Currently, we're using this function to retain timeseries metadata attributes, but it feels a bit hacky
def ts_resample(ts, freq="Y", agg="sum"):
tmp = TimeSeries.from_dataframe(ts.pd_dataframe().resample(freq).agg(agg))
tmp = tmp.with_static_covariates(ts.static_covariates)
tmp = tmp.with_hierarchy(ts.hierarchy)
return tmp
Describe the bug Hi, I'm trying to downsample a high-frequency Darts time series object to daily/monthly/yearly mean/sum/min/max etc. But the behavior is different than Pandas, so my only current option is to downsample before converting to a time series object.
To Reproduce
Results in
component Pounds per cow 10094.0 dtype: float64
Expected behavior Expected a time series with the sum of each year, rather than the sum of all years. That is the default behaviour of the pandas resample method and I'm having a hard time understanding why this wouldn't work in Darts.
System (please complete the following information):