-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
EnhancementNeeds TriageIssue that has not been reviewed by a pandas team memberIssue that has not been reviewed by a pandas team member
Description
While groupby throws a ValueError when the string parameter refers both to an index level and column name, query gives the column precedence in such a case:
>>> df = pd.DataFrame({'a':[1,2,3,4,5], 'b':[3,3,3,3,3]})
>>> df.index.name = 'a'
>>> df.query('a < b')
a b
a
0 1 3
1 2 3
>>> df.groupby('a')
Traceback (most recent call last):
ValueError: 'a' is both an index level and a column label, which is ambiguous.
I am sure there are many other places where a string can refer to both an index level and column name. #27652 and #8162 are somehow linked.
Even though those issues might not be solved, it would be desirable to handle the above ambiguity consistently in places where both index levels and column labels can be referenced by a string argument.
Metadata
Metadata
Assignees
Labels
EnhancementNeeds TriageIssue that has not been reviewed by a pandas team memberIssue that has not been reviewed by a pandas team member