diff --git a/pandas/core/series.py b/pandas/core/series.py index 0786674daf874..1b045b986ea01 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -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? diff --git a/pandas/tests/indexing/test_indexing.py b/pandas/tests/indexing/test_indexing.py index 98940b64330b4..21f8e3840e472 100644 --- a/pandas/tests/indexing/test_indexing.py +++ b/pandas/tests/indexing/test_indexing.py @@ -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__