-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: addtl fix for compat summary of groupby/resample with dicts #12329
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
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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.
I don't know if this is new in this PR (or if it already worked in master), but I don't think it is needed that we allow this? (in any case it errored in 0.17.1, so we can make a choice here)
Nested dicts don't seem to make much sense for SeriesGroupBy.
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.
And if we do this, shouldn't examples below give a MultiIndex?
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.
its not a nested dict, is exactly like the example that @xflr6 gave, that was my comment. The
A
acts on the actual data, while theB
acts on the SAME data (and NOT B), and is just 'named' BThere 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.
(groupby and resample work the same).
That was my point though. maybe we should raise here as the user could think they are actually operating on something they are not.
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.
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 had it doing like [4] at one point in time (whether you have a 'single' result or multiple as I agree its more consistent. But its ok where it is now, so I don't think should change unless its really compelling. Its clear by what you are passing what you should get back.
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.
It's just a bit strange and inconsistent that the key of the dict ('C') in [5] is completely ignored, while in [4] the keys of the dict are used as column names, while only the length of the dict differs
I would be +1 to raise here, but in the way it was in 0.17.1: raising for
g['D'].agg({'C': ['sum', 'std']})
but not forg['D'].agg({'C': 'sum', 'D': 'std']})
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.
in 0.17.1
I think [3] for 0.17.1 was just a bug. It should have worked.
Looking at this again, this is very tricky. When shoulud you raise? e.g. just because the key of the dict is not in the columns isn't good enough (or even if its a column in the top-level frame), it HAS to be a renaming key.
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.
ahh, but you would be ok with the current if
[4]
(from 0.18.0), has a multi-level index, right? (e.g.('C','sum'),('C','std')
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 (so key of dict is always seen as renaming key, independent of length of dict)
If we would want to raise, I think it should not depend on the value of the key (if it is equal to the column name or not), but on the dimension of the values (scalar -> then it is a simple renaming {'my_col_name': my_func} which is OK; when length > 1 -> then it can raise). But indeed probably easier to just allow it, but to be consistent in the handling of the keys as the column names in the multi-index