ENH: rolling mean with limited number of observations in a given period #47666
Labels
Enhancement
Needs Triage
Issue that has not been reviewed by a pandas team member
Window
rolling, ewma, expanding
Is your feature request related to a problem?
Calculate rolling mean for 10 days, but only for data points not older than 1 month.
Describe the solution you'd like
DataFrame.rolling
should get a new parametermax_periods
to describe the maximum number of data points taken into accountAPI breaking implications
N/A
Describe alternatives you've considered
With using
df.rolling(window='32D')
we can filter out the outdated values, but we cannot control the number of observations taken into account.With using
df.rolling(window=10)
we cannot control the number of observations, but we cannot filter out the outdated values taken into account.Additional context
Let's say we have 4 data points, 2 for the beginning of the year and 2 for the end of the year and we want to calculate rolling mean for the last 2 observations with exluding the too old data (older than 3 months)
df.rolling(window=10)
would not exclude Feb value when calculating mean for Nov.df.rolling(window='32D')
would not allow us to avoid calculating mean for more than 10 observations if the data is more dense within a given month.The text was updated successfully, but these errors were encountered: