diff --git a/doc/source/whatsnew/v0.17.0.txt b/doc/source/whatsnew/v0.17.0.txt index 4638cde1df2df..f94cc7d503b54 100644 --- a/doc/source/whatsnew/v0.17.0.txt +++ b/doc/source/whatsnew/v0.17.0.txt @@ -436,22 +436,22 @@ Deprecations .. note:: These indexing function have been deprecated in the documentation since 0.11.0. - For ``Series`` the following indexing functions are deprecated (:issue:`10177`). - ===================== ============================================================== - Deprecated Function Replacement - ===================== ============================================================== - ``.irow(i)`` ``.iloc[i]`` or ``.iat[i]`` - ``.iget(i)`` ``.iloc[i]`` or ``.iat[i]`` - ``.iget_value(i)`` ``.iloc[i]`` or ``.iat[i]`` - ===================== ============================================================== + ===================== ================================= + Deprecated Function Replacement + ===================== ================================= + ``.irow(i)`` ``.iloc[i]`` or ``.iat[i]`` + ``.iget(i)`` ``.iloc[i]`` + ``.iget_value(i)`` ``.iloc[i]`` or ``.iat[i]`` + ===================== ================================= - For ``DataFrame`` the following indexing functions are deprecated (:issue:`10177`). - ===================== ============================================================== - Deprecated Function Replacement - ===================== ============================================================== - ``.irow(i)`` ``.iloc[i]`` - ``.iget_value(i, j)`` ``.iloc[i, j]`` or ``.iat[i, j]`` - ``.icol(j)`` ``.iloc[:, j]`` - ===================== ============================================================== + ===================== ================================= + Deprecated Function Replacement + ===================== ================================= + ``.irow(i)`` ``.iloc[i]`` + ``.iget_value(i, j)`` ``.iloc[i, j]`` or ``.iat[i, j]`` + ``.icol(j)`` ``.iloc[:, j]`` + ===================== ================================= - ``Categorical.name`` was deprecated to make ``Categorical`` more ``numpy.ndarray`` like. Use ``Series(cat, name="whatever")`` instead (:issue:`10482`). diff --git a/pandas/core/series.py b/pandas/core/series.py index 47fdbbf777570..6586fa10935e6 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -794,7 +794,7 @@ def iget(self, i, axis=0): DEPRECATED. Use ``.iloc[i]`` or ``.iat[i]`` instead """ - warnings.warn("iget(i) is deprecated. Please use .iloc[i] or .iat[i]", + warnings.warn("iget(i) is deprecated. Please use .iloc[i]", FutureWarning, stacklevel=2) return self._ixs(i) diff --git a/pandas/tests/test_frame.py b/pandas/tests/test_frame.py index e42e72dcdda8f..3b93465c1efe9 100644 --- a/pandas/tests/test_frame.py +++ b/pandas/tests/test_frame.py @@ -1466,7 +1466,7 @@ def f(): self.assertTrue(result.values.all()) self.assertTrue((cp.iloc[0:1] == df.iloc[0:1]).values.all()) - warnings.filterwarnings(action='ignore', category=FutureWarning) + warnings.filterwarnings(action='default', category=FutureWarning) cp = df.copy() cp.iloc[4:5] = 0 @@ -2220,7 +2220,6 @@ class TestDataFrame(tm.TestCase, CheckIndexing, def setUp(self): import warnings - warnings.filterwarnings(action='ignore', category=FutureWarning) self.frame = _frame.copy() self.frame2 = _frame2.copy() diff --git a/pandas/tests/test_series.py b/pandas/tests/test_series.py index 4beba4ee3751c..b9931ff80ea86 100644 --- a/pandas/tests/test_series.py +++ b/pandas/tests/test_series.py @@ -577,7 +577,6 @@ class TestSeries(tm.TestCase, CheckNameIntegration): def setUp(self): import warnings - warnings.filterwarnings(action='ignore', category=FutureWarning) self.ts = _ts.copy() self.ts.name = 'ts' @@ -1145,14 +1144,28 @@ def test_getitem_get(self): self.assertIsNone(result) def test_iget(self): + s = Series(np.random.randn(10), index=lrange(0, 20, 2)) + + # 10711, deprecated + with tm.assert_produces_warning(FutureWarning): + s.iget(1) + + # 10711, deprecated + with tm.assert_produces_warning(FutureWarning): + s.irow(1) + + # 10711, deprecated + with tm.assert_produces_warning(FutureWarning): + s.iget_value(1) + for i in range(len(s)): - result = s.iget(i) + result = s.iloc[i] exp = s[s.index[i]] assert_almost_equal(result, exp) # pass a slice - result = s.iget(slice(1, 3)) + result = s.iloc[slice(1, 3)] expected = s.ix[2:4] assert_series_equal(result, expected) @@ -1161,13 +1174,13 @@ def test_iget(self): self.assertTrue((s[1:3] == 0).all()) # list of integers - result = s.iget([0, 2, 3, 4, 5]) + result = s.iloc[[0, 2, 3, 4, 5]] expected = s.reindex(s.index[[0, 2, 3, 4, 5]]) assert_series_equal(result, expected) def test_iget_nonunique(self): s = Series([0, 1, 2], index=[0, 1, 0]) - self.assertEqual(s.iget(2), 2) + self.assertEqual(s.iloc[2], 2) def test_getitem_regression(self): s = Series(lrange(5), index=lrange(5))