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: Deprecate Index.set_value #28621

Merged

Conversation

topper-123
Copy link
Contributor

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

Deprecates Index.set_value. This is a very little used and confusing method IMO.

For a given index idx, array arr, value idx_val in idx and a new value of val, idx.set_value(arr, idx_val, val) is equivalent to arr[idx.get_loc(idx_val) = val, which is more standard and should be used instead.

@topper-123 topper-123 added Deprecate Functionality to remove in pandas Index Related to the Index class or subclasses labels Sep 25, 2019
@jorisvandenbossche
Copy link
Member

There has been some discussion before about Index.get_value: #19728, where the thought was that this might be relied upon.
But in contrast to get_value, set_value is apparently something we don't use internally ourselves?

cc @shoyer

@topper-123
Copy link
Contributor Author

Yeah that's right, Index.set_value is not used by pandas itself.

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

I think this makes sense so OK by me

-
- :meth:`Index.set_values` has been deprecated. For a given index ``idx``, array ``arr``,
value in ``idx`` of ``idx_val`` and a new value of ``val``, ``idx.set_value(arr, idx_val, val)``
is equivalent to ``arr[idx.get_loc(idx_val) = val``, which should be used instead (:issue:`28621`).
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
is equivalent to ``arr[idx.get_loc(idx_val) = val``, which should be used instead (:issue:`28621`).
is equivalent to ``arr[idx.get_loc(idx_val) = val]``, which should be used instead (:issue:`28621`).

missing end bracket

@WillAyd WillAyd added this to the 1.0 milestone Oct 2, 2019
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

lgtm ping on green

@@ -116,7 +116,9 @@ Other API changes
Deprecations
~~~~~~~~~~~~

-
- :meth:`Index.set_values` has been deprecated. For a given index ``idx``, array ``arr``,
Copy link
Contributor

Choose a reason for hiding this comment

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

does this actually render? you should remove set_values from api.rst

@topper-123 topper-123 force-pushed the deprecate_set_value branch from 3a2befb to b708d92 Compare October 2, 2019 21:38
@topper-123
Copy link
Contributor Author

I've updated the PR according to comments.

In addition, I've added "set_value" to Index._deprecations.

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

lgtm @jreback

@jorisvandenbossche jorisvandenbossche merged commit bf6c5c3 into pandas-dev:master Oct 3, 2019
@jorisvandenbossche
Copy link
Member

Thanks!

galuhsahid added a commit to galuhsahid/pandas that referenced this pull request Oct 4, 2019
* master: (22 commits)
  DOC: fix PR09,PR08 errors for pandas.Timestamp (pandas-dev#28739)
  WEB: Add diversity note to team.md (pandas-dev#28630)
  DOC: Minor fixes in pandas/testing.py docstring. (pandas-dev#28752)
  TST: port maybe_promote tests from pandas-dev#23982 (pandas-dev#28764)
  Bugfix/groupby datetime issue (pandas-dev#28569)
  reenable codecov (pandas-dev#28750)
  CLN: Centralised _check_percentile (pandas-dev#27584)
  DEPR: Deprecate Index.set_value (pandas-dev#28621)
  CLN: Fix typo in contributing.rst (pandas-dev#28761)
  Fixed docstring errors in pandas.period range and pandas.PeriodIndex (pandas-dev#28756)
  BUG: Fix TypeError raised in libreduction (pandas-dev#28643)
  DOC: Pandas.Series.drop docstring PR02 (pandas-dev#27976) (pandas-dev#28742)
  DOC: Fixed doctring errors PR08, PR09 in pandas.io (pandas-dev#28748)
  TST: Fix broken test cases where Timedelta/Timestamp raise (pandas-dev#28729)
  REF: Consolidate alignment calls in DataFrame ops (pandas-dev#28638)
  BUG: Fix dep generation (pandas-dev#28734)
  Added doctstring to fixture (pandas-dev#28727)
  DOC: Fixed PR06 docstrings errors in pandas.timedelta_range (pandas-dev#28719)
  replaced safe_import with a corresponding test decorator (pandas-dev#28731)
  BUG: Fix RangeIndex.get_indexer for decreasing RangeIndex (pandas-dev#28680)
  ...
jbrockmendel pushed a commit to jbrockmendel/pandas that referenced this pull request Oct 8, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
bongolegend pushed a commit to bongolegend/pandas that referenced this pull request Jan 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Index Related to the Index class or subclasses
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants