resample¶
Defined in fynance.data
- resample(ps, freq, agg='last')[source]
Downsample a series to a coarser frequency.
The series index must be a NumPy
datetime64array; polars’group_by_dynamicresampling is defined only over a temporal axis. An integer or object-dtype (e.g.datetime.datetime) index is rejected with an explanatoryValueErrorrather than surfacing an opaque polars error.polars only accepts
datetime64resolutions[D],[ms],[us]and[ns]. Any other resolution (the common[s], plus[h],[m],[W],[M],[Y]) is losslessly upcast to[us]before resampling, so it works instead of triggering an opaque polars error.- Parameters:
- psPriceSeries
Series with a
datetime64index.- freqstr
Target polars frequency (e.g.
"1w","1mo").- agg{“last”, “mean”, “ohlc”}
Aggregation.
ohlcreturns a mapping with open/high/low/close.
- Returns:
- PriceSeries or dict of str to PriceSeries
The resampled series (or an open/high/low/close mapping for
ohlc).
- Raises:
- ValueError
If the index is not a
datetime64array, or ifaggis unknown.