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

Extending the grouper base argument #25226

Closed
LucaAmerio opened this issue Feb 8, 2019 · 1 comment · Fixed by #31809
Closed

Extending the grouper base argument #25226

LucaAmerio opened this issue Feb 8, 2019 · 1 comment · Fixed by #31809

Comments

@LucaAmerio
Copy link

LucaAmerio commented Feb 8, 2019

Problem description

pd.Grouper's base argument is almost undocumented (link). Despite this, the argument is extremely useful when grouping a dataframe with uneven sampling rate with an arbitrary start time.

Take for example the case of a dataframe representing a 60 minutes experiment with uneven sampling rate starting at '12-01-2019 11:55:23.01938' that we want to split in six 10-minutes group. base is our best ally here.

Despite this, in the current implementation base represents a floating number of minutes. It's however quite hard to understand what this number refers to, is quite cumbersome to convert the above '11:55:23.01938' into a number of minutes and gives you little flexibility regarding when the grouping will start.

This can also cause rounding error issues as descibed here.

I suggest replacing (or extend) this allowing it to be a datetime object so that the edge of each group is simply
base + N * freq
where N is an integer number. This is much cleaner and easy to understand.

@gfyoung
Copy link
Member

gfyoung commented Feb 9, 2019

cc @jreback regarding the enhancement

@pj1989 : We'll probably need to discuss the enhancement further, but in the meantime, documentation on base would definitely be appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants