Skip to content

Commit 3f11720

Browse files
Backport PR #42839: BUG: styler.hide_columns now hides the index name header row (#42867)
Co-authored-by: attack68 <[email protected]>
1 parent b908dc8 commit 3f11720

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

doc/source/whatsnew/v1.3.2.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Fixed regressions
3131
Bug fixes
3232
~~~~~~~~~
3333
- 1D slices over extension types turn into N-dimensional slices over ExtensionArrays (:issue:`42430`)
34-
-
34+
- :meth:`.Styler.hide_columns` now hides the index name header row as well as column headers (:issue:`42101`)
3535

3636
.. ---------------------------------------------------------------------------
3737

pandas/io/formats/style_render.py

+1
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ def _translate_header(
356356
self.data.index.names
357357
and com.any_not_none(*self.data.index.names)
358358
and not self.hide_index_
359+
and not self.hide_columns_
359360
):
360361
index_names = [
361362
_element(

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ def test_hide_column_headers(self):
11091109

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

11141114
def test_hide_single_index(self):
11151115
# GH 14194

0 commit comments

Comments
 (0)