Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: rolling mean with limited number of observations in a given period #47666

Open
dcsaba89 opened this issue Jul 11, 2022 · 0 comments
Open
Labels
Enhancement Needs Triage Issue that has not been reviewed by a pandas team member Window rolling, ewma, expanding

Comments

@dcsaba89
Copy link

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 parameter max_periods to describe the maximum number of data points taken into account

API 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.

@dcsaba89 dcsaba89 added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 11, 2022
@simonjayhawkins simonjayhawkins added the Window rolling, ewma, expanding label Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Needs Triage Issue that has not been reviewed by a pandas team member Window rolling, ewma, expanding
Projects
None yet
Development

No branches or pull requests

2 participants