-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG/REG: RollingGroupby MultiIndex levels dropped #38737
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
873317f
BUG/REG: RollingGroupby MultiIndex levels dropped
mroeschke 1c1c96c
Merge remote-tracking branch 'upstream/master' into bug/rolling_groupby
mroeschke 68beb5a
Merge remote-tracking branch 'upstream/master' into bug/rolling_groupby
mroeschke ac8612c
Merge remote-tracking branch 'upstream/master' into bug/rolling_groupby
mroeschke b0f3936
Merge remote-tracking branch 'upstream/master' into bug/rolling_groupby
mroeschke de68fa6
Merge branch 'master' into bug/rolling_groupby
simonjayhawkins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Are we sure this is the behaviour we want?
It might be the most consistent, but it's also kind of useless to repeat those index levels .. So we should at least have a way to avoid getting that?
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 would say the consistency is more maintainable on our end compared to additionally including logic to de-duplicate index levels given some condition.
I would prefer the user explicitly call
droplevel
.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.
hmm
so i think we are doing some magic in groupby for this. These are conceptually similar operations.
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.
Before indexers were implemented for
groupby().rolling()
, this was the result:which I think we should be trying to match. Though I'm not sure if we have solid conventions of the resulting index when using groupby.
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.
yep i see that. ok i think that we should revert for 1.2.x and then decide for 1.3 is prob ok. i am leaning towards have the same as groupby here.
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.
Okay once this is merged in I can create another issue to discuss what the index behavior should be for groupby rolling with duplicate index levels.
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.
When comparing to 1.0.5 behaviour, we also had:
So this PR then deviates from that for this case.
(I know the influence of
group_keys=False
has been considered a bug, but we could also reconsider that, since the above seems to actually give the desired result?)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.
The
group_keys
result different I think is due to the implementation change ingroupby().rolling()
Before
groupby().rolling()
under the hood wasgroupby().apply(lambda x: x.rolling()...)
and thereforegroup_keys
impacted the result (since the argument is only applicable forgroupby().apply()
).After
groupby().rolling()
moved away from usingapply
,group_keys
didn't impact the result.So IMO,
group_keys
shouldn't have ever really influenced the result sincegroupby().apply()
was never called directly from the user.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.
can you add testing for group_keys in any event?
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.
Yes that's parameterized here already: https://github.com/pandas-dev/pandas/pull/38737/files#diff-e338c43cbd06b849f3d6a1b97cd787a48770c616b627f33eb20f67a6fc56b116R559