10000 DEPR/API: disallow lists within list for set_index by h-vetinari · Pull Request #24697 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

DEPR/API: disallow lists within list for set_index #24697

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

Closed
wants to merge 23 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
bf0eee0
DEPR/API: disallow lists within list for set_index
h-vetinari Jan 10, 2019
ed0de1f
Add deprecation and whatsnew
h-vetinari Jan 10, 2019
dc274e3
restore test for list-of-scalars interpreted as keys
h-vetinari Jan 10, 2019
623fc9a
Small doc fixes
h-vetinari Jan 10, 2019
5f6e303
Improve docstring; small fixes
h-vetinari Jan 10, 2019
13d4e40
Merge remote-tracking branch 'upstream/master' into depr_LL_set_index
h-vetinari Jan 10, 2019
813b4fc
Remove last mention of "list-like"
h-vetinari Jan 10, 2019
4c130ee
rephrase "illegal"
h-vetinari Jan 10, 2019
8731834
Merge remote-tracking branch 'upstream/master' into depr_LL_set_index
h-vetinari Jan 10, 2019
29fbc6a
Merge remote-tracking branch 'upstream/master' into depr_LL_set_index
h-vetinari Jan 14, 2019
cc04a64
Merge remote-tracking branch 'upstream/master' into depr_LL_set_index
h-vetinari Jan 14, 2019
e1d999b
Improve warning message (review TomAugspurger)
h-vetinari Jan 14, 2019
726ef1c
typo
h-vetinari Jan 14, 2019
0e1f709
Merge remote-tracking branch 'upstream/master' into depr_LL_set_index
h-vetinari Jan 16, 2019
b0b326f
Tuples always considered keys; KeyError, not ValueError if missing
h-vetinari Jan 16, 2019
6cbcc47
Merge remote-tracking branch 'upstream/master' into depr_LL_set_index
h-vetinari Jan 20, 2019
c881aaa
Merge remote-tracking branch 'upstream/master' into depr_LL_set_index
h-vetinari Feb 24, 2019
0214801
Actually commit fix for conflict, duh
h-vetinari Feb 24, 2019
61c511d
Move whatsnew to 0.25
h-vetinari Feb 24, 2019
7381245
Merge remote-tracking branch 'upstream/master' into depr_LL_set_index
h-vetinari Mar 1, 2019
5fa544c
Add deprecation-section (review jreback)
h-vetinari Mar 1, 2019
a016bf0
Merge remote-tracking branch 'upstream/master' into depr_LL_set_index
h-vetinari Mar 3, 2019
0c65876
Fix doc fails
h-vetinari Mar 3, 2019
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
Prev Previous commit
Next Next commit
Add deprecation-section (review jreback)
  • Loading branch information
h-vetinari committed Mar 1, 2019
commit 5fa544c5858725b792332a958db2f518f8fa8d12
28 changes: 27 additions & 1 deletion doc/source/whatsnew/v0.25.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,34 @@ Other API Changes
Deprecations
~~~~~~~~~~~~

**Lists as arrays in :meth:`DataFrame.set_index`**

Currently, :meth:`DataFrame.set_index` accepts lists as meaning two different things - as a list of labels, and as an array-like collection of values.
This ambiguity decides in favor of the list of labels, but nested lists are interpreted as arrays:

.. ipython:: ipython
:okwarning:

df = pd.DataFrame(np.reshape(np.arange(12), (3, 4)), columns=['a', 'b', 'c', 'd'])
df.set_index(['a', 'b', 'c'])
df.set_index([['a', 'b', 'c']])

The latter case has now been deprecated and will be removed in a future version. As a replacement,
it is suggested to wrap the list in a :class:`Series`, :class:`Index`, ``np.array`` or an iterator.

.. ipython:: ipython

df.set_index(pd.Series(['a', 'b', 'c']))

It remains possible to use lists as collecting several column keys or arrays to create multiple levels of a :class:`MultiIndex`.

.. ipython:: ipython

df.set_index(['a', pd.Series(['a', 'b', 'c'])])

**Other deprecations**

- Deprecated the `M (months)` and `Y (year)` `units` parameter of :func: `pandas.to_timedelta`, :func: `pandas.Timedelta` and :func: `pandas.TimedeltaIndex` (:issue:`16344`)
- :meth:`DataFrame.set_index` has deprecated using lists of values *within* lists. It remains possible to pass array-likes, both directly and within a list.

.. _whatsnew_0250.prior_deprecations:

Expand Down
0