@@ -3568,6 +3568,7 @@ def _wrap(x, alt_format_):
3568
3568
elif formatters is None and float_format is not None :
3569
3569
formatters_ = partial (_wrap , alt_format_ = lambda v : v )
3570
3570
format_index_ = [index_format_ , column_format_ ]
3571
+ format_index_names_ = [index_format_ , column_format_ ]
3571
3572
3572
3573
# Deal with hiding indexes and relabelling column names
3573
3574
hide_ : list [dict ] = []
@@ -3584,6 +3585,7 @@ def _wrap(x, alt_format_):
3584
3585
elif isinstance (header , (list , tuple )):
3585
3586
relabel_index_ .append ({"labels" : header , "axis" : "columns" })
3586
3587
format_index_ = [index_format_ ] # column_format is overwritten
3588
+ format_index_names_ = [index_format_ ] # column_format is overwritten
3587
3589
3588
3590
if index is False :
3589
3591
hide_ .append ({"axis" : "index" })
@@ -3616,6 +3618,7 @@ def _wrap(x, alt_format_):
3616
3618
relabel_index = relabel_index_ ,
3617
3619
format = {"formatter" : formatters_ , ** base_format_ },
3618
3620
format_index = format_index_ ,
3621
+ format_index_names = format_index_names_ ,
3619
3622
render_kwargs = render_kwargs_ ,
3620
3623
)
3621
3624
@@ -3628,6 +3631,7 @@ def _to_latex_via_styler(
3628
3631
relabel_index : dict | list [dict ] | None = None ,
3629
3632
format : dict | list [dict ] | None = None ,
3630
3633
format_index : dict | list [dict ] | None = None ,
3634
+ format_index_names : dict | list [dict ] | None = None ,
3631
3635
render_kwargs : dict | None = None ,
3632
3636
):
3633
3637
"""
@@ -3672,7 +3676,13 @@ def _to_latex_via_styler(
3672
3676
self = cast ("DataFrame" , self )
3673
3677
styler = Styler (self , uuid = "" )
3674
3678
3675
- for kw_name in ["hide" , "relabel_index" , "format" , "format_index" ]:
3679
+ for kw_name in [
3680
+ "hide" ,
3681
+ "relabel_index" ,
3682
+ "format" ,
3683
+ "format_index" ,
3684
+ "format_index_names" ,
3685
+ ]:
3676
3686
kw = vars ()[kw_name ]
3677
3687
if isinstance (kw , dict ):
3678
3688
getattr (styler , kw_name )(** kw )
0 commit comments