Skip to content

ENH: Having rolling accepts pd.IntervalIndex on a sorted datetime column #40702

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

Closed
yohplala opened this issue Mar 31, 2021 · 1 comment
Closed
Labels
Enhancement Window rolling, ewma, expanding

Comments

@yohplala
Copy link

yohplala commented Mar 31, 2021

Describe the solution you'd like

It is currently possible to define custom window rolling as explained in documentation.

It is required to subclass BaseIndexer and define ones' own get_window_bounds.

In case windows' bounds are defined by timestamps, pandas already provide a nice API to define them as pd.IntervalIndex.

Requested feature is to have rolling accepting pd.IntervalIndex in window parameter, that would be used in combination with on parameter to define the datetime-like column (already the case apparently)

API breaking implications

window parameter accepts pd.IntervalIndex

Additional context

This operation could be managed by use of pd.IntervalIndex and pd.cut but this combination does not take advantage that:

  • intervals are sorted and non overlapping
  • datetime-like column is sorted
    which allows then to go through the DataFrame only once, managing each intervals one after the other.

I think that rolling naturally does.

@yohplala yohplala added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 31, 2021
@mroeschke mroeschke added Window rolling, ewma, expanding and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 31, 2021
@yohplala
Copy link
Author

yohplala commented Apr 30, 2021

Hi,
Sorry, I think I made a mix between 'rolling' and 'resample/groubly'. I have open ticket #41212 with a similar request, but focused on 'resample' and providing a more detailed use case. I am closing this one. Sorry for the mistake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Window rolling, ewma, expanding
Projects
None yet
Development

No branches or pull requests

2 participants