-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
BUG: Error raised accessing tuple value in Series when index contains duplicates #37800
Comments
Similar problems with loc. Index does not have to be non-unique there
Tuple support is not very good here. |
This is conflicting with the multiindex selector which uses tuple as the label for different levels. >>>s = pd.Series([1, 1], index=pd.Index([(1, 2), (1, 1)]))
>>>s.loc[(1,2)]
1 Ambiguous when using tuple index. |
@GYHHAHA what is ambiguous? When Series has a multi-index, a tuple consists of labels for different levels. When Series doesn't have a multi-index, a tuple is a single label. Or is there some other case(s)? |
>>>s = pd.Series([1,2], index=pd.Index([((1,1),1),((1,2),2)]))
>>>s.loc[(1,1)]
1 1
dtype: int64 When tuple index is the zero level of multiindex. But it seems still reasonable when applying to a non-multiindex. |
Ack, I see. A similar example:
one might expect to get |
E.g.
raises
KeyError: (1, 1)
. Withinpandas._libs.index.IndexEngine._get_loc_duplicates
, we're using ndarray.searchsorted which interprets the tuple as an array-like of values to search for rather than a single tuple.The text was updated successfully, but these errors were encountered: