Skip to content

BUG: styler.hide_columns now hides the index name header row #42839

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 1 commit into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.3.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Fixed regressions
Bug fixes
~~~~~~~~~
- 1D slices over extension types turn into N-dimensional slices over ExtensionArrays (:issue:`42430`)
-
- :meth:`.Styler.hide_columns` now hides the index name header row as well as column headers (:issue:`42101`)

.. ---------------------------------------------------------------------------

Expand Down
1 change: 1 addition & 0 deletions pandas/io/formats/style_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ def _translate_header(
self.data.index.names
and com.any_not_none(*self.data.index.names)
and not self.hide_index_
and not self.hide_columns_
):
index_names = [
_element(
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/formats/style/test_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ def test_hide_column_headers(self):

self.df.index.name = "some_name"
ctx = self.df.style.hide_columns()._translate(True, True)
assert len(ctx["head"]) == 1 # only a single row for index names: no col heads
assert len(ctx["head"]) == 0 # no header for index names, changed in #42101

def test_hide_single_index(self):
# GH 14194
Expand Down