-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: RollingGroupby when groupby key is in the index #37661
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
BUG: RollingGroupby when groupby key is in the index #37661
Conversation
This will remove an index label in the case of partial overlap between the index labels and the groupby labels; I am wondering if a more natural behavior here would be "add any groupby labels to the index if they aren't already there". |
Not sure if I 100% follow, but this is the resulting index behavior I am trying to mimic here:
|
Shouldn't I almost never use rolling in my work so I don't have much of an opinion as to what the right behavior is. Just noticed what I think is an inconsistency. |
Yes groupby.rolling should essentially act as a transform, and I think in both test cases I added the resulting shape (number of rows) is maintained with consideration that not all columns should be maintained since one of the columns was a grouping key.
|
doc/source/whatsnew/v1.2.0.rst
Outdated
@@ -535,6 +535,7 @@ Groupby/resample/rolling | |||
- Bug in :meth:`df.groupby(..).quantile() <pandas.core.groupby.DataFrameGroupBy.quantile>` and :meth:`df.resample(..).quantile() <pandas.core.resample.Resampler.quantile>` raised ``TypeError`` when values were of type ``Timedelta`` (:issue:`29485`) | |||
- Bug in :meth:`Rolling.median` and :meth:`Rolling.quantile` returned wrong values for :class:`BaseIndexer` subclasses with non-monotonic starting or ending points for windows (:issue:`37153`) | |||
- Bug in :meth:`DataFrame.groupby` dropped ``nan`` groups from result with ``dropna=False`` when grouping over a single column (:issue:`35646`, :issue:`35542`) | |||
- Bug in :meth:`RollingGroupby` with the resulting :class:`MultiIndex` when grouping by a label that is in the index (:issue:`37641`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this is ok to backport ton 1.1.5 if possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this fixes a regression from 1.0.5 -> 1.1.0, so backport is preferable.
thanks @mroeschke |
@meeseeksdev backport 1.1.x |
This comment has been minimized.
This comment has been minimized.
…n groupby key is in the index
…key is in the index (#37741) Co-authored-by: Matthew Roeschke <[email protected]>
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff