Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ def _get_with(self, key):
indexer = self.index.get_indexer_for(key)
return self.iloc[indexer]
else:
return self._get_values(key)
return self.iloc[key]

if isinstance(key, (list, tuple)):
# TODO: de-dup with tuple case handled above?
Expand Down
31 changes: 8 additions & 23 deletions pandas/tests/indexing/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,33 +80,18 @@ def test_getitem_ndarray_3d(self, index, obj, idxr, idxr_id):
idxr = idxr(obj)
nd3 = np.random.randint(5, size=(2, 2, 2))

msg = (
r"Buffer has wrong number of dimensions \(expected 1, "
r"got 3\)|"
"Cannot index with multidimensional key|"
r"Wrong number of dimensions. values.ndim != ndim \[3 != 1\]|"
"Index data must be 1-dimensional"
msg = "|".join(
[
r"Buffer has wrong number of dimensions \(expected 1, got 3\)",
"Cannot index with multidimensional key",
r"Wrong number of dimensions. values.ndim != ndim \[3 != 1\]",
"Index data must be 1-dimensional",
]
)

if (
isinstance(obj, Series)
and idxr_id == "getitem"
and index.inferred_type
in [
"string",
"datetime64",
"period",
"timedelta64",
"boolean",
"categorical",
]
):
with pytest.raises(ValueError, match=msg):
with tm.assert_produces_warning(DeprecationWarning, check_stacklevel=False):
idxr[nd3]
else:
with pytest.raises(ValueError, match=msg):
with tm.assert_produces_warning(DeprecationWarning):
idxr[nd3]

@pytest.mark.parametrize(
"index", tm.all_index_generator(5), ids=lambda x: type(x).__name__
Expand Down