8000 ENH: Allow the groupby by param to handle columns and index levels (GH5677) by jonmmease · Pull Request #14432 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Implemented GH 5677
  • Loading branch information
Jon M. Mease committed Nov 18, 2016
commit 355d70904fe2f5fc82826d58eca78e2dfaa6435e
9 changes: 7 additions & 2 deletions pandas/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -2449,8 +2449,13 @@ def is_in_obj(gpr):
exclusions.append(name)

elif is_in_axis(gpr): # df.groupby('name')
in_axis, name, gpr = True, gpr, obj[gpr]
exclusions.append(name)
if gpr in obj:
in_axis, name, gpr = True, gpr, obj[gpr]
exclusions.append(name)
elif gpr in obj.index.names:
in_axis, name, level, gpr = False, None, gpr, None
else:
raise KeyError(gpr)
elif isinstance(gpr, Grouper) and gpr.key is not None:
# Add key to exclusions
exclusions.append(gpr.key)
Expand Down
0