Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 2 additions & 5 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,11 +949,8 @@ def _get_with(self, key):
else:
return self.iloc[key]

if isinstance(key, list):
# handle the dup indexing case GH#4246
return self.loc[key]

return self.reindex(key)
# handle the dup indexing case GH#4246
return self.loc[key]

def _get_values_tuple(self, key):
# mpl hackaround
Expand Down
5 changes: 0 additions & 5 deletions pandas/tests/series/indexing/test_boolean.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ def test_getitem_boolean_empty():

# GH5877
# indexing with empty series
s = Series(["A", "B"])
expected = Series(np.nan, index=["C"], dtype=object)
result = s[Series(["C"], dtype=object)]
tm.assert_series_equal(result, expected)

s = Series(["A", "B"])
expected = Series(dtype=object, index=Index([], dtype="int64"))
result = s[Series([], dtype=object)]
Expand Down
12 changes: 12 additions & 0 deletions pandas/tests/series/indexing/test_getitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@ def test_getitem_median_slice_bug(self):


class TestSeriesGetitemListLike:
@pytest.mark.parametrize("box", [list, np.array, pd.Index, pd.Series])
def test_getitem_no_matches(self, box):
# GH#33462 we expect the same behavior for list/ndarray/Index/Serioes
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Serioes -> Series

ser = Series(["A", "B"])

key = Series(["C"], dtype=object)
key = box(key)

msg = r"None of \[Index\(\['C'\], dtype='object'\)\] are in the \[index\]"
with pytest.raises(KeyError, match=msg):
ser[key]

def test_getitem_intlist_intindex_periodvalues(self):
ser = Series(period_range("2000-01-01", periods=10, freq="D"))

Expand Down