Skip to content

Commit

Permalink
xref #10711, remove more iget warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jreback committed Aug 2, 2015
1 parent ae30697 commit 22eb63c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 22 deletions.
28 changes: 14 additions & 14 deletions doc/source/whatsnew/v0.17.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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`).

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
23 changes: 18 additions & 5 deletions pandas/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)

Expand All @@ -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))
Expand Down

0 comments on commit 22eb63c

Please sign in to comment.