What to do with future Ambiguity Error about overlapping names when sorting?
See original GitHub issuexref https://github.com/pandas-dev/pandas/pull/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
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
Merge, join, concatenate and compare - Pandas
This will result in an ambiguity error in a future version. Overlapping value columns#. The merge suffixes argument takes a tuple of list...
Read more >A PivotTable report cannot overlap another ... - MyExcelOnline
Steps To Fix Overlapping Pivot Tables in Excel. DOWNLOAD EXCEL WORKBOOK. STEP 1: Let us see the error in action. Right click on...
Read more >Merge with Caution: How to Avoid Common Problems ... - SAS
This paper examines several common issues, provides examples to illustrate what can go wrong and why, and discusses best practices to avoid unintended ......
Read more >Innovations and challenges in detecting long read overlaps
These error-corrected reads can then be overlapped again with higher ... Though the computational cost incurred by sorting the list can negatively impact ......
Read more >XSL Transformations (XSLT) Version 3.0 - W3C
As an implementer option, XSLT 3.0 can also be used with XPath 3.1. ... There is no ambiguity, and no error, if several...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

To be clear, I’m OK with going down this road of “indexes are a special type of column, so don’t have overlapping names”. Perhaps we’ll use this issue to collect use-cases where they arise, and document how to avoid them?
e.g. the last one would be something like “use
groupby('a', as_index=False)”.It is not ambiguous when I specify
axis=0.But the warning still.