Skip to content

Change MultiIndex repr (labels -> codes) #24731

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

Merged
merged 2 commits into from
Jan 13, 2019

Conversation

topper-123
Copy link
Contributor

@topper-123 topper-123 commented Jan 11, 2019

As I mentioned in #22511 (comment), the repr for MultiIndex ATM uses labels, even though the parameter/attribute has been changed to codes.

>>> mi = pd.MultiIndex.from_product([[8,9,0], ['a', 'b', 'c']])
>>> MultiIndex(levels=[[0, 8, 9], ['a', 'b', 'c']],
...            labels=[[1, 1, 1, 2, 2, 2, 0, 0, 0], [0, 1, 2, 0, 1, 2, 0, 1, 2]])

This PR changes the repr, so it uses codes.

Fot the record I think we should either decide to adapt #22511 soon, or soon come up with an consensus about an alternative repr to be implemented. The current MultiIndex repr is really, really (really!) bad for large indexes and needs to be be changed.

@codecov
Copy link

codecov bot commented Jan 11, 2019

Codecov Report

Merging #24731 into master will decrease coverage by 49.32%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           master   #24731       +/-   ##
===========================================
- Coverage   92.39%   43.07%   -49.33%     
===========================================
  Files         166      166               
  Lines       52358    52358               
===========================================
- Hits        48374    22551    -25823     
- Misses       3984    29807    +25823
Flag Coverage Δ
#multiple ?
#single 43.07% <ø> (-0.03%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/multi.py 34.88% <ø> (-60.71%) ⬇️
pandas/core/strings.py 33% <ø> (-65.59%) ⬇️
pandas/core/indexes/base.py 56.54% <ø> (-39.77%) ⬇️
pandas/io/formats/latex.py 0% <0%> (-100%) ⬇️
pandas/core/categorical.py 0% <0%> (-100%) ⬇️
pandas/io/sas/sas_constants.py 0% <0%> (-100%) ⬇️
pandas/tseries/plotting.py 0% <0%> (-100%) ⬇️
pandas/tseries/converter.py 0% <0%> (-100%) ⬇️
pandas/io/formats/html.py 0% <0%> (-99.35%) ⬇️
pandas/core/groupby/categorical.py 0% <0%> (-95.46%) ⬇️
... and 126 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 fdc4db2...88fb789. Read the comment docs.

@codecov
Copy link

codecov bot commented Jan 11, 2019

Codecov Report

Merging #24731 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #24731   +/-   ##
=======================================
  Coverage   92.39%   92.39%           
=======================================
  Files         166      166           
  Lines       52358    52358           
=======================================
  Hits        48374    48374           
  Misses       3984     3984
Flag Coverage Δ
#multiple 90.81% <ø> (ø) ⬆️
#single 43.07% <ø> (-0.03%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/multi.py 95.58% <ø> (ø) ⬆️
pandas/core/strings.py 98.58% <ø> (ø) ⬆️
pandas/core/indexes/base.py 96.3% <ø> (ø) ⬆️

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 fdc4db2...7a8d8b2. Read the comment docs.

@topper-123 topper-123 force-pushed the MultiIndex._format_attrs branch from 88fb789 to 7a8d8b2 Compare January 11, 2019 21:24
@gfyoung gfyoung added Output-Formatting __repr__ of pandas objects, to_string MultiIndex labels Jan 11, 2019
@jreback jreback added this to the 0.24.0 milestone Jan 13, 2019
@jreback jreback merged commit f02b548 into pandas-dev:master Jan 13, 2019
@jreback
Copy link
Contributor

jreback commented Jan 13, 2019

thanks @topper-123

@topper-123 topper-123 deleted the MultiIndex._format_attrs branch January 13, 2019 19:49
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MultiIndex Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants