BUG: Pandas loc can result in ambiguous result not caught by an exception #42603
Labels
Bug
Indexing
Related to indexing on series/frames, not to indexes themselves
Needs Discussion
Requires discussion from core team before further action
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample
Tested on Pandas 1.3.0.
Problem description
When converting arrays to DataFrames, the columns will automatically be enumerated. Obviously this problem is somewhat circumventable by not doing all these implicit conversions. However, it doesn't warn you of this, and the case I describe above can return a Series or a DataFrame, depending on which index you query for, which, at least for me, created a decent amount of confusion.
Expected Output
I'd imagine it should raise an ambiguity error, similar to #21080, like
The text was updated successfully, but these errors were encountered: