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

ENH: DataFrame.style sparsified MultiIndex #13775

Closed

Conversation

TomAugspurger
Copy link
Contributor

Notebook comparing DataFrame._html_repr_ to DataFrame.style

I think we're identical for non-truncated DataFrames. That' has not been implemented in Styler yet.

Along the way I noticed two other things that ended up needing fixing.

  1. DataFrame.columns.names were not displayed
  2. CSS classes weren't being assigned correctly to row labels.

The fixes ended up being pretty intertwined, so I've put them in a single PR. Unfortunately, the commits are a bit jumbled as well :/

@TomAugspurger TomAugspurger added the Output-Formatting __repr__ of pandas objects, to_string label Jul 24, 2016
@TomAugspurger TomAugspurger added this to the 0.19.0 milestone Jul 24, 2016
@@ -314,6 +314,8 @@ Other enhancements
- ``Series.append`` now supports the ``ignore_index`` option (:issue:`13677`)
- ``.to_stata()`` and ``StataWriter`` can now write variable labels to Stata dta files using a dictionary to make column names to labels (:issue:`13535`, :issue:`13536`)
- ``.to_stata()`` and ``StataWriter`` will automatically convert ``datetime64[ns]`` columns to Stata format ``%tc``, rather than raising a ``ValueError`` (:issue:`12259`)
- ``DataFrame.style`` will now render sparsified MultiIndexes (:issue:`11655`)
- ``DataFrame.style`` will now show column names (:issue:``)
Copy link
Contributor

Choose a reason for hiding this comment

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

use the pr number

@TomAugspurger
Copy link
Contributor Author

maybe put a ref to the style docs (e.g. not sure how much of an example is needed here)

@jreback this was undocumented... Adding this section to the notebook. Will push soon.

CSS Classes

Certain CSS classes are attached to cells.

  • Index and Column names include index_name and level<k> where k is its level in a MultiIndex
  • Index label cells include
    • row_heading
    • row<n> where n is the numeric position of the row
    • level<k> where k is the level in a MultiIndex
  • Column label cells include
    • col_heading
    • col<n> where n is the numeric position of the column
    • level<k> where k is the level in a MultiIndex
  • Blank cells include blank
  • Data cells include data

@codecov-io
Copy link

codecov-io commented Jul 25, 2016

Current coverage is 85.24% (diff: 100%)

Merging #13775 into master will increase coverage by <.01%

@@             master     #13775   diff @@
==========================================
  Files           140        140          
  Lines         50415      50440    +25   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          42970      42996    +26   
+ Misses         7445       7444     -1   
  Partials          0          0          

Powered by Codecov. Last update 98c5b88...7c03a72

@@ -314,6 +314,8 @@ Other enhancements
- ``Series.append`` now supports the ``ignore_index`` option (:issue:`13677`)
- ``.to_stata()`` and ``StataWriter`` can now write variable labels to Stata dta files using a dictionary to make column names to labels (:issue:`13535`, :issue:`13536`)
- ``.to_stata()`` and ``StataWriter`` will automatically convert ``datetime64[ns]`` columns to Stata format ``%tc``, rather than raising a ``ValueError`` (:issue:`12259`)
- ``DataFrame.style`` will now render sparsified MultiIndexes (:issue:`11655`)
- ``DataFrame.style`` will now show column names (:issue:`13775`)
Copy link
Member

Choose a reason for hiding this comment

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

'column names' -> 'column level names' ? ('column names' sounds like the columns labels itself)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 DataFrame.style will now show column level names (e.g. DataFrame.columns.names) (:issue:13775)

BUG: Fix index class level row

MVP

Columns too

tests
"\n",
"Certain CSS classes are attached to cells.\n",
"\n",
"- Index and Column names include `index_name` and `level<k>` where `k` is its level in a MultiIndex\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

would add this documenation to the doc-string as well

BUG: Fix CSS classes for index names

Updates

doc2

option

honor options
@jreback
Copy link
Contributor

jreback commented Aug 3, 2016

lgtm. merge away.

@TomAugspurger TomAugspurger deleted the style-sparse-mi-2 branch April 5, 2017 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Conditional HTML styling hides MultiIndex structure
4 participants