Skip to content

What to do with future Ambiguity Error about overlapping names when sorting? #21081

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
TomAugspurger opened this issue May 16, 2018 · 2 comments

Comments

@TomAugspurger
Copy link
Contributor

TomAugspurger commented May 16, 2018

xref #17361

In [24]: df = pd.DataFrame({"a": [1, 2], "b": [3, 4]}, index=pd.Index([1, 2], name='a'))

In [25]: df.sort_values(['a', 'b'])
/Users/taugspurger/.virtualenvs/pandas-dev/bin/ipython:1: FutureWarning: 'a' is both an index level and a column label.
Defaulting to column, but this will raise an ambiguity error in a future version
  #!/Users/taugspurger/Envs/pandas-dev/bin/python3
Out[25]:
   a  b
a
1  1  3
2  2  4

What should the user do in this situation? Should we provide a keyword to disambiguate? A literal like pd.ColumnLabel('a') or pd.IndexName('a')? Or do we require that they rename an index or column? Right now, they're essentially stuck with the last one. If we want to discourage that, then I suppose that's OK. But it's somewhat common to end up with overlapping names, from e.g. a groupby.

cc @jmmease

@TomAugspurger TomAugspurger added this to the 0.23.1 milestone May 16, 2018
@TomAugspurger TomAugspurger changed the title What to do with future Ambiguity Error when sorting What to do with future Ambiguity Error about overlapping names when sorting? May 16, 2018
@jorisvandenbossche
Copy link
Member

jorisvandenbossche commented May 16, 2018

This is exactly the same as #21080 ?

@jorisvandenbossche
Copy link
Member

I updated #21080 with the additional text you had here

@jorisvandenbossche jorisvandenbossche modified the milestones: 0.23.1, No action May 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants