Skip to content

BUG: position indexing in getitem with duplicated index #11747

Closed
@jreback

Description

@jreback

in py3, the following should correctly raise an IndexError

In [1]: s = Series(range(5),index=list('aacde'))

In [2]: s[5]
IndexError

however
a positional indexer that is in the range should work
s[3]

Further more, this must be a monotonic increasing duplicated index to trigger

In [8]: Series(range(5),index=list('aabcd'))[3]
IndexError: 3

In [9]: Series(range(5),index=list('aadcb'))[3]
Out[9]: 3

simple change needed here
in that if its an integer and in the range of the index it can return that value.

Though maybe we should just detect this in the cython code (index.pyx/Index/_get_loc_duplicated)

needless to say, no tests for this :<

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions