Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEPR: remove previously-deprecated get_value, set_value #27377

Merged
merged 12 commits into from
Jul 24, 2019
Merged
Show file tree
Hide file tree
Changes from 5 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
185 changes: 185 additions & 0 deletions doc/source/whatsnew/v0.26.0.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
:orphan:

.. TODO. Remove the orphan tag.

.. _whatsnew_0260:

What's new in 0.26.0 (July XX, 2019)
------------------------------------

Enhancements
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added as 1.0, so this can be removed

~~~~~~~~~~~~


.. _whatsnew_0260.enhancements.other:

Other enhancements
^^^^^^^^^^^^^^^^^^

-
-
-

.. _whatsnew_0260.deprecations:

Deprecations
~~~~~~~~~~~~

-
-

.. _whatsnew_0260.prior_deprecations:

Removal of prior version deprecations/changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Removed the previously deprecated :meth:`Series.get_value`, :meth:`Series.set_value`, :meth:`DataFrame.get_value`, :meth:`DataFrame.set_value` (:issue:`17739`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to 1.0

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved



.. _whatsnew_0260.bug_fixes:

Bug fixes
~~~~~~~~~


Categorical
^^^^^^^^^^^

-
-
-

Datetimelike
^^^^^^^^^^^^

-
-
-

Timedelta
^^^^^^^^^

-
-
-

Timezones
^^^^^^^^^

-
-
-

Numeric
^^^^^^^
-
-
-

Conversion
^^^^^^^^^^

-
-
-

Strings
^^^^^^^

-
-
-


Interval
^^^^^^^^

-
-
-

Indexing
^^^^^^^^

-
-
-

Missing
^^^^^^^

-
-
-

MultiIndex
^^^^^^^^^^

-
-
-

I/O
^^^

-
-
-

Plotting
^^^^^^^^

-
-
-

Groupby/resample/rolling
^^^^^^^^^^^^^^^^^^^^^^^^

-
-
-

Reshaping
^^^^^^^^^

-
-
-

Sparse
^^^^^^

-
-
-


Build Changes
^^^^^^^^^^^^^

-
-
-

ExtensionArray
^^^^^^^^^^^^^^

-
-
-

Other
^^^^^

-
-
-

.. _whatsnew_0.260.contributors:

Contributors
~~~~~~~~~~~~

.. TODO. Change to v0.26.0..HEAD

.. contributors:: HEAD..HEAD
38 changes: 3 additions & 35 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def _constructor(self):

_constructor_sliced = Series # type: Type[Series]
_deprecations = NDFrame._deprecations | frozenset(
["get_value", "set_value", "from_items"]
["from_items"]
) # type: FrozenSet[str]
_accessors = set() # type: Set[str]

Expand Down Expand Up @@ -2787,13 +2787,10 @@ def _unpickle_matrix_compat(self, state): # pragma: no cover
# ----------------------------------------------------------------------
# Getting and setting elements

def get_value(self, index, col, takeable=False):
def _get_value(self, index, col, takeable: bool = False):
"""
Quickly retrieve single value at passed column and index.

.. deprecated:: 0.21.0
Use .at[] or .iat[] accessors instead.

Parameters
----------
index : row label
Expand All @@ -2804,18 +2801,6 @@ def get_value(self, index, col, takeable=False):
-------
scalar
"""

warnings.warn(
"get_value is deprecated and will be removed "
"in a future release. Please use "
".at[] or .iat[] accessors instead",
FutureWarning,
stacklevel=2,
)
return self._get_value(index, col, takeable=takeable)

def _get_value(self, index, col, takeable=False):

if takeable:
series = self._iget_item_cache(col)
return com.maybe_box_datetimelike(series._values[index])
Expand All @@ -2839,15 +2824,10 @@ def _get_value(self, index, col, takeable=False):
index = self.index.get_loc(index)
return self._get_value(index, col, takeable=True)

_get_value.__doc__ = get_value.__doc__

def set_value(self, index, col, value, takeable=False):
def _set_value(self, index, col, value, takeable: bool = False):
"""
Put single value at passed column and index.

.. deprecated:: 0.21.0
Use .at[] or .iat[] accessors instead.

Parameters
----------
index : row label
Expand All @@ -2861,16 +2841,6 @@ def set_value(self, index, col, value, takeable=False):
If label pair is contained, will be reference to calling DataFrame,
otherwise a new object.
"""
warnings.warn(
"set_value is deprecated and will be removed "
"in a future release. Please use "
".at[] or .iat[] accessors instead",
FutureWarning,
stacklevel=2,
)
return self._set_value(index, col, value, takeable=takeable)

def _set_value(self, index, col, value, takeable=False):
try:
if takeable is True:
series = self._iget_item_cache(col)
Expand All @@ -2891,8 +2861,6 @@ def _set_value(self, index, col, value, takeable=False):

return self

_set_value.__doc__ = set_value.__doc__

def _ixs(self, i: int, axis: int = 0):
"""
Parameters
Expand Down
38 changes: 4 additions & 34 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class Series(base.IndexOpsMixin, generic.NDFrame):
_accessors = {"dt", "cat", "str", "sparse"}
# tolist is not actually deprecated, just suppressed in the __dir__
_deprecations = generic.NDFrame._deprecations | frozenset(
["asobject", "reshape", "get_value", "set_value", "valid", "tolist"]
["asobject", "reshape", "valid", "tolist"]
)

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

def get_value(self, label, takeable=False):
def _get_value(self, label, takeable: bool = False):
"""
Quickly retrieve single value at passed index label.

.. deprecated:: 0.21.0
Please use .at[] or .iat[] accessors.

Parameters
----------
label : object
Expand All @@ -1383,29 +1380,14 @@ def get_value(self, label, takeable=False):
-------
scalar value
"""
warnings.warn(
"get_value is deprecated and will be removed "
"in a future release. Please use "
".at[] or .iat[] accessors instead",
FutureWarning,
stacklevel=2,
)
return self._get_value(label, takeable=takeable)

def _get_value(self, label, takeable=False):
if takeable is True:
if takeable:
return com.maybe_box_datetimelike(self._values[label])
return self.index.get_value(self._values, label)

_get_value.__doc__ = get_value.__doc__

def set_value(self, label, value, takeable=False):
def _set_value(self, label, value, takeable: bool = False):
"""
Quickly set single value at passed label.

.. deprecated:: 0.21.0
Please use .at[] or .iat[] accessors.

If label is not contained, a new object is created with the label
placed at the end of the result index.

Expand All @@ -1423,16 +1405,6 @@ def set_value(self, label, value, takeable=False):
If label is contained, will be reference to calling Series,
otherwise a new object.
"""
warnings.warn(
"set_value is deprecated and will be removed "
"in a future release. Please use "
".at[] or .iat[] accessors instead",
FutureWarning,
stacklevel=2,
)
return self._set_value(label, value, takeable=takeable)

def _set_value(self, label, value, takeable=False):
try:
if takeable:
self._values[label] = value
Expand All @@ -1445,8 +1417,6 @@ def _set_value(self, label, value, takeable=False):

return self

_set_value.__doc__ = set_value.__doc__

def reset_index(self, level=None, drop=False, name=None, inplace=False):
"""
Generate a new DataFrame or Series with the index reset.
Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/frame/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ def test_getitem_pop_assign_name(self, float_frame):
def test_get_value(self, float_frame):
for idx in float_frame.index:
for col in float_frame.columns:
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
result = float_frame.get_value(idx, col)
result = float_frame._get_value(idx, col)
expected = float_frame[col][idx]
tm.assert_almost_equal(result, expected)

Expand Down
12 changes: 4 additions & 8 deletions pandas/tests/frame/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,8 @@ def test_constructor_dict(self):
# Dict with None value
frame_none = DataFrame(dict(a=None), index=[0])
frame_none_list = DataFrame(dict(a=[None]), index=[0])
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
assert frame_none.get_value(0, "a") is None
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
assert frame_none_list.get_value(0, "a") is None
assert frame_none._get_value(0, "a") is None
assert frame_none_list._get_value(0, "a") is None
tm.assert_frame_equal(frame_none, frame_none_list)

# GH10856
Expand Down Expand Up @@ -702,17 +700,15 @@ def test_nested_dict_frame_constructor(self):
data = {}
for col in df.columns:
for row in df.index:
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
data.setdefault(col, {})[row] = df.get_value(row, col)
data.setdefault(col, {})[row] = df._get_value(row, col)

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

data = {}
for col in df.columns:
for row in df.index:
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
data.setdefault(row, {})[col] = df.get_value(row, col)
data.setdefault(row, {})[col] = df._get_value(row, col)

result = DataFrame(data, index=rng).T
tm.assert_frame_equal(result, df)
Expand Down
Loading