Skip to content

BUG: positional getitem indexing with list on Series with duplicate integer index fails #26083

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

Merged
merged 8 commits into from
Apr 16, 2019
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pandas/tests/indexing/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,15 @@ def test_index_type_coercion(self):
idxr(s2)['0'] = 0
assert s2.index.is_object()

def test_duplicate_int_indexing(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use parameterize like

@pytest.parameterize('case', [lambda s: s.__getitem__, lambda: s.loc])
def test_duplicate_int_indexing(self, case):
     expected = s.iloc[[1]]
     result = case(s)[[1]]

# GH 17347
s = pd.Series(range(3), index=[1, 1, 3])
expected = s[1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this after def test_dups_fancy_indexing2(self)

result = s[[1]]
result2 = s.loc[[1]]
tm.assert_series_equal(result, expected)
tm.assert_series_equal(result2, expected)


class TestMisc(Base):

Expand Down