Skip to content

Commit 0b02137

Browse files
jbrockmendeljreback
authored andcommitted
DEPR: remove previously-deprecated get_value, set_value (#27377)
* DEPR: remove previously-deprecated get_value, set_value * start 0.26.0 file, move deprecation removal there * whitespace fixup * move note to 1.0 file * also remove for Sparse * remove usages of get_value, set_value
1 parent d6b443c commit 0b02137

File tree

12 files changed

+48
-193
lines changed

12 files changed

+48
-193
lines changed

doc/source/whatsnew/v1.0.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Deprecations
6060

6161
Removal of prior version deprecations/changes
6262
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
63-
63+
- Removed the previously deprecated :meth:`Series.get_value`, :meth:`Series.set_value`, :meth:`DataFrame.get_value`, :meth:`DataFrame.set_value` (:issue:`17739`)
6464
-
6565
-
6666

pandas/core/frame.py

+3-35
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ def _constructor(self):
382382

383383
_constructor_sliced = Series # type: Type[Series]
384384
_deprecations = NDFrame._deprecations | frozenset(
385-
["get_value", "set_value", "from_items"]
385+
["from_items"]
386386
) # type: FrozenSet[str]
387387
_accessors = set() # type: Set[str]
388388

@@ -2779,13 +2779,10 @@ def _unpickle_matrix_compat(self, state): # pragma: no cover
27792779
# ----------------------------------------------------------------------
27802780
# Getting and setting elements
27812781

2782-
def get_value(self, index, col, takeable=False):
2782+
def _get_value(self, index, col, takeable: bool = False):
27832783
"""
27842784
Quickly retrieve single value at passed column and index.
27852785
2786-
.. deprecated:: 0.21.0
2787-
Use .at[] or .iat[] accessors instead.
2788-
27892786
Parameters
27902787
----------
27912788
index : row label
@@ -2796,18 +2793,6 @@ def get_value(self, index, col, takeable=False):
27962793
-------
27972794
scalar
27982795
"""
2799-
2800-
warnings.warn(
2801-
"get_value is deprecated and will be removed "
2802-
"in a future release. Please use "
2803-
".at[] or .iat[] accessors instead",
2804-
FutureWarning,
2805-
stacklevel=2,
2806-
)
2807-
return self._get_value(index, col, takeable=takeable)
2808-
2809-
def _get_value(self, index, col, takeable=False):
2810-
28112796
if takeable:
28122797
series = self._iget_item_cache(col)
28132798
return com.maybe_box_datetimelike(series._values[index])
@@ -2831,15 +2816,10 @@ def _get_value(self, index, col, takeable=False):
28312816
index = self.index.get_loc(index)
28322817
return self._get_value(index, col, takeable=True)
28332818

2834-
_get_value.__doc__ = get_value.__doc__
2835-
2836-
def set_value(self, index, col, value, takeable=False):
2819+
def _set_value(self, index, col, value, takeable: bool = False):
28372820
"""
28382821
Put single value at passed column and index.
28392822
2840-
.. deprecated:: 0.21.0
2841-
Use .at[] or .iat[] accessors instead.
2842-
28432823
Parameters
28442824
----------
28452825
index : row label
@@ -2853,16 +2833,6 @@ def set_value(self, index, col, value, takeable=False):
28532833
If label pair is contained, will be reference to calling DataFrame,
28542834
otherwise a new object.
28552835
"""
2856-
warnings.warn(
2857-
"set_value is deprecated and will be removed "
2858-
"in a future release. Please use "
2859-
".at[] or .iat[] accessors instead",
2860-
FutureWarning,
2861-
stacklevel=2,
2862-
)
2863-
return self._set_value(index, col, value, takeable=takeable)
2864-
2865-
def _set_value(self, index, col, value, takeable=False):
28662836
try:
28672837
if takeable is True:
28682838
series = self._iget_item_cache(col)
@@ -2883,8 +2853,6 @@ def _set_value(self, index, col, value, takeable=False):
28832853

28842854
return self
28852855

2886-
_set_value.__doc__ = set_value.__doc__
2887-
28882856
def _ixs(self, i: int, axis: int = 0):
28892857
"""
28902858
Parameters

pandas/core/series.py

+4-34
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class Series(base.IndexOpsMixin, generic.NDFrame):
179179
_accessors = {"dt", "cat", "str", "sparse"}
180180
# tolist is not actually deprecated, just suppressed in the __dir__
181181
_deprecations = generic.NDFrame._deprecations | frozenset(
182-
["asobject", "reshape", "get_value", "set_value", "valid", "tolist"]
182+
["asobject", "reshape", "valid", "tolist"]
183183
)
184184

185185
# Override cache_readonly bc Series is mutable
@@ -1367,13 +1367,10 @@ def repeat(self, repeats, axis=None):
13671367
new_values = self._values.repeat(repeats)
13681368
return self._constructor(new_values, index=new_index).__finalize__(self)
13691369

1370-
def get_value(self, label, takeable=False):
1370+
def _get_value(self, label, takeable: bool = False):
13711371
"""
13721372
Quickly retrieve single value at passed index label.
13731373
1374-
.. deprecated:: 0.21.0
1375-
Please use .at[] or .iat[] accessors.
1376-
13771374
Parameters
13781375
----------
13791376
label : object
@@ -1383,29 +1380,14 @@ def get_value(self, label, takeable=False):
13831380
-------
13841381
scalar value
13851382
"""
1386-
warnings.warn(
1387-
"get_value is deprecated and will be removed "
1388-
"in a future release. Please use "
1389-
".at[] or .iat[] accessors instead",
1390-
FutureWarning,
1391-
stacklevel=2,
1392-
)
1393-
return self._get_value(label, takeable=takeable)
1394-
1395-
def _get_value(self, label, takeable=False):
1396-
if takeable is True:
1383+
if takeable:
13971384
return com.maybe_box_datetimelike(self._values[label])
13981385
return self.index.get_value(self._values, label)
13991386

1400-
_get_value.__doc__ = get_value.__doc__
1401-
1402-
def set_value(self, label, value, takeable=False):
1387+
def _set_value(self, label, value, takeable: bool = False):
14031388
"""
14041389
Quickly set single value at passed label.
14051390
1406-
.. deprecated:: 0.21.0
1407-
Please use .at[] or .iat[] accessors.
1408-
14091391
If label is not contained, a new object is created with the label
14101392
placed at the end of the result index.
14111393
@@ -1423,16 +1405,6 @@ def set_value(self, label, value, takeable=False):
14231405
If label is contained, will be reference to calling Series,
14241406
otherwise a new object.
14251407
"""
1426-
warnings.warn(
1427-
"set_value is deprecated and will be removed "
1428-
"in a future release. Please use "
1429-
".at[] or .iat[] accessors instead",
1430-
FutureWarning,
1431-
stacklevel=2,
1432-
)
1433-
return self._set_value(label, value, takeable=takeable)
1434-
1435-
def _set_value(self, label, value, takeable=False):
14361408
try:
14371409
if takeable:
14381410
self._values[label] = value
@@ -1445,8 +1417,6 @@ def _set_value(self, label, value, takeable=False):
14451417

14461418
return self
14471419

1448-
_set_value.__doc__ = set_value.__doc__
1449-
14501420
def reset_index(self, level=None, drop=False, name=None, inplace=False):
14511421
"""
14521422
Generate a new DataFrame or Series with the index reset.

pandas/core/sparse/frame.py

+2-30
Original file line numberDiff line numberDiff line change
@@ -447,12 +447,10 @@ def sp_maker(x, index=None):
447447
# always return a SparseArray!
448448
return clean
449449

450-
def get_value(self, index, col, takeable=False):
450+
def _get_value(self, index, col, takeable=False):
451451
"""
452452
Quickly retrieve single value at passed column and index
453453
454-
.. deprecated:: 0.21.0
455-
456454
Please use .at[] or .iat[] accessors.
457455
458456
Parameters
@@ -465,31 +463,17 @@ def get_value(self, index, col, takeable=False):
465463
-------
466464
value : scalar value
467465
"""
468-
warnings.warn(
469-
"get_value is deprecated and will be removed "
470-
"in a future release. Please use "
471-
".at[] or .iat[] accessors instead",
472-
FutureWarning,
473-
stacklevel=2,
474-
)
475-
return self._get_value(index, col, takeable=takeable)
476-
477-
def _get_value(self, index, col, takeable=False):
478466
if takeable is True:
479467
series = self._iget_item_cache(col)
480468
else:
481469
series = self._get_item_cache(col)
482470

483471
return series._get_value(index, takeable=takeable)
484472

485-
_get_value.__doc__ = get_value.__doc__
486-
487-
def set_value(self, index, col, value, takeable=False):
473+
def _set_value(self, index, col, value, takeable=False):
488474
"""
489475
Put single value at passed column and index
490476
491-
.. deprecated:: 0.21.0
492-
493477
Please use .at[] or .iat[] accessors.
494478
495479
Parameters
@@ -509,23 +493,11 @@ def set_value(self, index, col, value, takeable=False):
509493
-------
510494
frame : DataFrame
511495
"""
512-
warnings.warn(
513-
"set_value is deprecated and will be removed "
514-
"in a future release. Please use "
515-
".at[] or .iat[] accessors instead",
516-
FutureWarning,
517-
stacklevel=2,
518-
)
519-
return self._set_value(index, col, value, takeable=takeable)
520-
521-
def _set_value(self, index, col, value, takeable=False):
522496
dense = self.to_dense()._set_value(index, col, value, takeable=takeable)
523497
return dense.to_sparse(
524498
kind=self._default_kind, fill_value=self._default_fill_value
525499
)
526500

527-
_set_value.__doc__ = set_value.__doc__
528-
529501
def _slice(self, slobj, axis=0, kind=None):
530502
if axis == 0:
531503
new_index = self.index[slobj]

pandas/core/sparse/series.py

+2-29
Original file line numberDiff line numberDiff line change
@@ -386,12 +386,10 @@ def get(self, label, default=None):
386386
else:
387387
return default
388388

389-
def get_value(self, label, takeable=False):
389+
def _get_value(self, label, takeable=False):
390390
"""
391391
Retrieve single value at passed index label
392392
393-
.. deprecated:: 0.21.0
394-
395393
Please use .at[] or .iat[] accessors.
396394
397395
Parameters
@@ -403,23 +401,10 @@ def get_value(self, label, takeable=False):
403401
-------
404402
value : scalar value
405403
"""
406-
warnings.warn(
407-
"get_value is deprecated and will be removed "
408-
"in a future release. Please use "
409-
".at[] or .iat[] accessors instead",
410-
FutureWarning,
411-
stacklevel=2,
412-
)
413-
414-
return self._get_value(label, takeable=takeable)
415-
416-
def _get_value(self, label, takeable=False):
417404
loc = label if takeable is True else self.index.get_loc(label)
418405
return self._get_val_at(loc)
419406

420-
_get_value.__doc__ = get_value.__doc__
421-
422-
def set_value(self, label, value, takeable=False):
407+
def _set_value(self, label, value, takeable=False):
423408
"""
424409
Quickly set single value at passed label. If label is not contained, a
425410
new object is created with the label placed at the end of the result
@@ -446,16 +431,6 @@ def set_value(self, label, value, takeable=False):
446431
-------
447432
series : SparseSeries
448433
"""
449-
warnings.warn(
450-
"set_value is deprecated and will be removed "
451-
"in a future release. Please use "
452-
".at[] or .iat[] accessors instead",
453-
FutureWarning,
454-
stacklevel=2,
455-
)
456-
return self._set_value(label, value, takeable=takeable)
457-
458-
def _set_value(self, label, value, takeable=False):
459434
values = self.to_dense()
460435

461436
# if the label doesn't exist, we will create a new object here
@@ -468,8 +443,6 @@ def _set_value(self, label, value, takeable=False):
468443
self._data = SingleBlockManager(values, new_index)
469444
self._index = new_index
470445

471-
_set_value.__doc__ = set_value.__doc__
472-
473446
def _set_values(self, key, value):
474447

475448
# this might be inefficient as we have to recreate the sparse array

pandas/tests/frame/test_api.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ def test_getitem_pop_assign_name(self, float_frame):
6767
def test_get_value(self, float_frame):
6868
for idx in float_frame.index:
6969
for col in float_frame.columns:
70-
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
71-
result = float_frame.get_value(idx, col)
70+
result = float_frame._get_value(idx, col)
7271
expected = float_frame[col][idx]
7372
tm.assert_almost_equal(result, expected)
7473

pandas/tests/frame/test_constructors.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,8 @@ def test_constructor_dict(self):
329329
# Dict with None value
330330
frame_none = DataFrame(dict(a=None), index=[0])
331331
frame_none_list = DataFrame(dict(a=[None]), index=[0])
332-
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
333-
assert frame_none.get_value(0, "a") is None
334-
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
335-
assert frame_none_list.get_value(0, "a") is None
332+
assert frame_none._get_value(0, "a") is None
333+
assert frame_none_list._get_value(0, "a") is None
336334
tm.assert_frame_equal(frame_none, frame_none_list)
337335

338336
# GH10856
@@ -702,17 +700,15 @@ def test_nested_dict_frame_constructor(self):
702700
data = {}
703701
for col in df.columns:
704702
for row in df.index:
705-
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
706-
data.setdefault(col, {})[row] = df.get_value(row, col)
703+
data.setdefault(col, {})[row] = df._get_value(row, col)
707704

708705
result = DataFrame(data, columns=rng)
709706
tm.assert_frame_equal(result, df)
710707

711708
data = {}
712709
for col in df.columns:
713710
for row in df.index:
714-
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
715-
data.setdefault(row, {})[col] = df.get_value(row, col)
711+
data.setdefault(row, {})[col] = df._get_value(row, col)
716712

717713
result = DataFrame(data, index=rng).T
718714
tm.assert_frame_equal(result, df)

0 commit comments

Comments
 (0)