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

API: rename MultiIndex.labels to MultiIndex.codes #23752

Merged
merged 12 commits into from
Dec 5, 2018

Conversation

topper-123
Copy link
Contributor

@topper-123 topper-123 commented Nov 17, 2018

This PR renames MultiIndex.labels to MultiIndex.codes.

Also note that I've not changed the repr method or the repr output in various doc strings examples in anticipation of #22511 (this would be unneeded extra work). This should all be ok when #22511 is merged.

I would appreciate comments on the changes quickly, as this is a very large PR that touches on many parts of pandas, so it quickly gets out of sync.

@jorisvandenbossche?

@topper-123 topper-123 force-pushed the MultiIndex.codes branch 6 times, most recently from 135a58f to cf4060e Compare November 17, 2018 14:03
@gfyoung gfyoung added API Design MultiIndex Deprecate Functionality to remove in pandas labels Nov 18, 2018
@topper-123 topper-123 force-pushed the MultiIndex.codes branch 6 times, most recently from 867c24c to fc2c214 Compare November 18, 2018 19:00
@codecov
Copy link

codecov bot commented Nov 18, 2018

Codecov Report

Merging #23752 into master will increase coverage by <.01%.
The diff coverage is 95.76%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #23752      +/-   ##
==========================================
+ Coverage    92.2%    92.2%   +<.01%     
==========================================
  Files         162      162              
  Lines       51714    51724      +10     
==========================================
+ Hits        47682    47692      +10     
  Misses       4032     4032
Flag Coverage Δ
#multiple 90.6% <93.81%> (ø) ⬆️
#single 43.02% <27.03%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/window.py 96.39% <ø> (ø) ⬆️
pandas/core/groupby/generic.py 87.07% <0%> (ø) ⬆️
pandas/core/util/hashing.py 98.4% <100%> (ø) ⬆️
pandas/core/reshape/reshape.py 99.56% <100%> (ø) ⬆️
pandas/core/indexes/base.py 96.32% <100%> (ø) ⬆️
pandas/core/groupby/ops.py 96.72% <100%> (ø) ⬆️
pandas/core/reshape/merge.py 94.28% <100%> (ø) ⬆️
pandas/core/sparse/frame.py 94.84% <100%> (ø) ⬆️
pandas/util/testing.py 87.41% <100%> (ø) ⬆️
pandas/core/panel.py 97.91% <100%> (ø) ⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9f2c716...a8d00ad. Read the comment docs.

pandas/core/indexes/multi.py Show resolved Hide resolved
pandas/core/indexes/multi.py Show resolved Hide resolved
pandas/core/indexes/multi.py Show resolved Hide resolved
pandas/core/indexes/multi.py Outdated Show resolved Hide resolved
@topper-123
Copy link
Contributor Author

I've updated now. The Travis failure is unrelated (it's a unrelated test that consumes too much memory):

Worker 'gw1' crashed while running 'pandas/tests/series/test_rank.py::test_pct_max_many_rows'

I've also caught/done a few more renames, see latest commit.

I'll start up updating the docs tonight or tomorrow. I'll do the doc changes in a seperate PR, as the current PR already is very large.

topper-123 added a commit to topper-123/pandas that referenced this pull request Nov 21, 2018
@topper-123 topper-123 force-pushed the MultiIndex.codes branch 2 times, most recently from 6f741ee to ae3877b Compare November 22, 2018 18:39
topper-123 added a commit to topper-123/pandas that referenced this pull request Nov 22, 2018
topper-123 added a commit to topper-123/pandas that referenced this pull request Nov 24, 2018
@jreback jreback merged commit aead29b into pandas-dev:master Dec 5, 2018
@jreback
Copy link
Contributor

jreback commented Dec 5, 2018

thanks @topper-123 nice change!

@topper-123 topper-123 deleted the MultiIndex.codes branch December 5, 2018 19:55
@jorisvandenbossche
Copy link
Member

Thanks a lot for this @topper-123 !

TomAugspurger added a commit to TomAugspurger/pandas that referenced this pull request Dec 6, 2018
commit 28c61d770f6dfca6857fd0fa6979d4119a31129e
Author: Tom Augspurger <tom.w.augspurger@gmail.com>
Date:   Thu Dec 6 12:18:19 2018 -0600

    uncomment

commit bae2e322523efc73a1344464f51611e2dc555ccb
Author: Tom Augspurger <tom.w.augspurger@gmail.com>
Date:   Thu Dec 6 12:17:09 2018 -0600

    maybe fixes

commit 6cb4db05c9d6ceba3794096f0172cae5ed5f6019
Author: Tom Augspurger <tom.w.augspurger@gmail.com>
Date:   Thu Dec 6 09:57:37 2018 -0600

    we back

commit d97ab57fb32cb23371169d9ed659ccfac34cfe45
Merge: a117de4 b78aa8d
Author: Tom Augspurger <tom.w.augspurger@gmail.com>
Date:   Thu Dec 6 09:51:51 2018 -0600

    Merge remote-tracking branch 'upstream/master' into disown-tz-only-rebased2

commit b78aa8d
Author: gfyoung <gfyoung17+GitHub@gmail.com>
Date:   Thu Dec 6 07:18:44 2018 -0500

    REF/TST: Add pytest idiom to reshape/test_tile (pandas-dev#24107)

commit 2993b8e
Author: gfyoung <gfyoung17+GitHub@gmail.com>
Date:   Thu Dec 6 07:17:55 2018 -0500

    REF/TST: Add more pytest idiom to scalar/test_nat (pandas-dev#24120)

commit b841374
Author: evangelineliu <hsiyinliu@gmail.com>
Date:   Wed Dec 5 18:21:46 2018 -0500

    BUG: Fix concat series loss of timezone (pandas-dev#24027)

commit 4ae63aa
Author: jbrockmendel <jbrockmendel@gmail.com>
Date:   Wed Dec 5 14:44:50 2018 -0800

    Implement DatetimeArray._from_sequence (pandas-dev#24074)

commit 2643721
Author: jbrockmendel <jbrockmendel@gmail.com>
Date:   Wed Dec 5 14:43:45 2018 -0800

    CLN: Follow-up to pandas-dev#24100 (pandas-dev#24116)

commit 8ea7744
Author: chris-b1 <cbartak@gmail.com>
Date:   Wed Dec 5 14:21:23 2018 -0600

    PERF: ascii c string functions (pandas-dev#23981)

commit cb862e4
Author: jbrockmendel <jbrockmendel@gmail.com>
Date:   Wed Dec 5 12:19:46 2018 -0800

    BUG: fix mutation of DTI backing Series/DataFrame (pandas-dev#24096)

commit aead29b
Author: topper-123 <contribute@tensortable.com>
Date:   Wed Dec 5 19:06:00 2018 +0000

    API: rename MultiIndex.labels to MultiIndex.codes (pandas-dev#23752)
@jorisvandenbossche
Copy link
Member

There are still a bunch of warnings in the docs that should be fixed:

>>>-------------------------------------------------------------------------
Warning in /home/travis/build/pandas-dev/pandas/doc/source/io.rst at block ending on line 4631
Specify :okwarning: as an option in the ipython:: block to suppress this message
----------------------------------------------------------------------------
/home/travis/miniconda3/envs/pandas-dev/lib/python3.6/site-packages/pyarrow/pandas_compat.py:742: FutureWarning: .labels was deprecated in version 0.24.0. Use .codes instead.
  labels, = index.labels
<<<-------------------------------------------------------------------------
>>>-------------------------------------------------------------------------
Warning in /home/travis/build/pandas-dev/pandas/doc/source/io.rst at block ending on line 4704
Specify :okwarning: as an option in the ipython:: block to suppress this message
----------------------------------------------------------------------------
/home/travis/miniconda3/envs/pandas-dev/lib/python3.6/site-packages/pyarrow/pandas_compat.py:698: FutureWarning: .labels was deprecated in version 0.24.0. Use .codes instead.
  labels = getattr(columns, 'labels', None) or [
<<<-------------------------------------------------------------------------
>>>-------------------------------------------------------------------------
Warning in /home/travis/build/pandas-dev/pandas/doc/source/io.rst at block ending on line 4704
Specify :okwarning: as an option in the ipython:: block to suppress this message
----------------------------------------------------------------------------
/home/travis/miniconda3/envs/pandas-dev/lib/python3.6/site-packages/pyarrow/pandas_compat.py:725: FutureWarning: the 'labels' keyword is deprecated, use 'codes' instead
  return pd.MultiIndex(levels=new_levels, labels=labels, names=columns.names)
<<<-------------------------------------------------------------------------
>>>-------------------------------------------------------------------------
Warning in /home/travis/build/pandas-dev/pandas/doc/source/io.rst at block ending on line 4704
Specify :okwarning: as an option in the ipython:: block to suppress this message
----------------------------------------------------------------------------
/home/travis/miniconda3/envs/pandas-dev/lib/python3.6/site-packages/pyarrow/pandas_compat.py:742: FutureWarning: .labels was deprecated in version 0.24.0. Use .codes instead.
  labels, = index.labels
<<<-------------------------------------------------------------------------
>>>-------------------------------------------------------------------------
Warning in /home/travis/build/pandas-dev/pandas/doc/source/io.rst at block ending on line 4768
Specify :okwarning: as an option in the ipython:: block to suppress this message
----------------------------------------------------------------------------
/home/travis/miniconda3/envs/pandas-dev/lib/python3.6/site-packages/pyarrow/pandas_compat.py:698: FutureWarning: .labels was deprecated in version 0.24.0. Use .codes instead.
  labels = getattr(columns, 'labels', None) or [
<<<-------------------------------------------------------------------------
>>>-------------------------------------------------------------------------
Warning in /home/travis/build/pandas-dev/pandas/doc/source/io.rst at block ending on line 4768
Specify :okwarning: as an option in the ipython:: block to suppress this message
----------------------------------------------------------------------------
/home/travis/miniconda3/envs/pandas-dev/lib/python3.6/site-packages/pyarrow/pandas_compat.py:725: FutureWarning: the 'labels' keyword is deprecated, use 'codes' instead
  return pd.MultiIndex(levels=new_levels, labels=labels, names=columns.names)
<<<-------------------------------------------------------------------------
>>>-------------------------------------------------------------------------
Warning in /home/travis/build/pandas-dev/pandas/doc/source/io.rst at block ending on line 4768
Specify :okwarning: as an option in the ipython:: block to suppress this message
----------------------------------------------------------------------------
/home/travis/miniconda3/envs/pandas-dev/lib/python3.6/site-packages/pyarrow/pandas_compat.py:742: FutureWarning: .labels was deprecated in version 0.24.0. Use .codes instead.
  labels, = index.labels
<<<-------------------------------------------------------------------------

@jorisvandenbossche
Copy link
Member

Ah, they all seem to come from parquet / feather. Will report upstream.

@jorisvandenbossche
Copy link
Member

There are some other in the whatsnew files as well

Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
andrewsanchez added a commit to andrewsanchez/q2-diversity that referenced this pull request Feb 12, 2020
nbokulich pushed a commit to qiime2/q2-diversity that referenced this pull request Feb 14, 2020
* Use MultiIndex.codes instead of labels (no longer support)

Please see these links for the rational if interested:

pandas-dev/pandas#13443

pandas-dev/pandas#23752

* Unpack and name values returned by _reindex_with_metadata

This makes it easier to see what's going on below with the values
returned by this function.

* Initial patch to handle new pandas error

This prevents attempting to drop columns that don't exist in merged.columns
after setting the index, while still dropping columns that are present in
merged.columns.  Attempting to do so raises an exception in pandas >= 1.

Please see pandas-dev/pandas#8594
for details.

* Avoid mutating `merged` in place by assigning to new variable

This avoids attempting to drop columns that had already been dropped in previous
calls to _reindex_with_metadata in the for loop in `alpha_rarefaction`.

Co-authored-by: Matthew Dillon <matthewrdillon@gmail.com>

Co-authored-by: Matthew Dillon <matthewrdillon@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Deprecate Functionality to remove in pandas MultiIndex
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API: MultiIndex.labels -> codes
4 participants