Open dylan-lee94 opened 9 months ago
Do I understand you correctly that you'd want a mininum_span
parameter such that when the samples in the window span a period in length less than this quantity null is returned?
If so we could consider adding that after the rework into rolling
and rolling_interval
, but it would be blocking work right now.
Yes exactly. In the above described example, with a dynamic mininum_span
argument of 1mo
I would expect the function to return values once the window spans a period length from 2022-02-02 to 2022-03-02 (depending on closed
argument).
Description
I'm using polars.Expr.rolling_sum for stock return calculations, in particular for computing 1 month trailing stock returns. Here it would be great if
min_periods
ensures that the 1 month trailing return isNull
when there is not enough data available for the entire window size.Let's create some dummy stock returns
In the current implementation,
min_periods
is set to 1, if window_size is a dynamic temporal size.It would be great to allow
min_periods
to take a dynamic temporal size, similarly to:I am not entirely sure, but this might already be addressed by #12049.