Skip to content

Commit b1f7e58

Browse files
authored
BUG?: hide_columns now doesn't hide index names (#43404)
1 parent 0625e99 commit b1f7e58

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

doc/source/whatsnew/v1.4.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Styler
7676
- :meth:`.Styler.bar` introduces additional arguments to control alignment and display (:issue:`26070`, :issue:`36419`), and it also validates the input arguments ``width`` and ``height`` (:issue:`42511`).
7777
- :meth:`.Styler.to_latex` introduces keyword argument ``environment``, which also allows a specific "longtable" entry through a separate jinja2 template (:issue:`41866`).
7878
- :meth:`.Styler.to_html` introduces keyword arguments ``sparse_index``, ``sparse_columns``, ``bold_headers``, ``caption`` (:issue:`41946`, :issue:`43149`).
79-
- Keyword argument ``level`` is added to :meth:`.Styler.hide_index` and :meth:`.Styler.hide_columns` for optionally controlling hidden levels in a MultiIndex (:issue:`25475`)
79+
- Keyword arguments ``level`` and ``names`` added to :meth:`.Styler.hide_index` and :meth:`.Styler.hide_columns` for additional control of visibility of MultiIndexes and index names (:issue:`25475`, :issue:`43404`, :issue:`43346`)
8080
- Global options have been extended to configure default ``Styler`` properties including formatting and encoding and mathjax options and LaTeX (:issue:`41395`)
8181

8282
Formerly Styler relied on ``display.html.use_mathjax``, which has now been replaced by ``styler.html.mathjax``.

pandas/io/formats/style_render.py

-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,6 @@ def _translate_header(
387387
self.data.index.names
388388
and com.any_not_none(*self.data.index.names)
389389
and not all(self.hide_index_)
390-
and not all(self.hide_columns_)
391390
and not self.hide_index_names
392391
):
393392
index_names = [

pandas/tests/io/formats/style/test_style.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,8 @@ def test_hide_column_headers(self):
10621062

10631063
self.df.index.name = "some_name"
10641064
ctx = self.df.style.hide_columns()._translate(True, True)
1065-
assert len(ctx["head"]) == 0 # no header for index names, changed in #42101
1065+
assert len(ctx["head"]) == 1
1066+
# index names still visible, changed in #42101, reverted in 43404
10661067

10671068
def test_hide_single_index(self):
10681069
# GH 14194

0 commit comments

Comments
 (0)