@@ -556,23 +556,30 @@ def apply_column_style(self, cols_to_style, styler_obj, style_header=False, use_
556556
557557 return self
558558
559- def apply_headers_style (self , styler_obj , style_index_header = True ):
559+ def apply_headers_style (self , styler_obj , style_index_header = True , cols_to_style = None ):
560560 """Apply style to the headers only
561-
562561 :param Styler styler_obj: the styler object that contains the style to be applied
563562 :param bool style_index_header: if True then the style will also be applied to the header of the index column
563+ :param None|str|list|tuple|set cols_to_style: the columns to apply the style to, if not provided all the columns will be styled
564564 :return: self
565565 :rtype: StyleFrame
566566 """
567567
568568 if not isinstance (styler_obj , Styler ):
569569 raise TypeError ('styler_obj must be {}, got {} instead.' .format (Styler .__name__ , type (styler_obj ).__name__ ))
570570
571+ if cols_to_style is None :
572+ cols_to_style = self .data_df .columns
573+ if not isinstance (cols_to_style , (list , tuple , set , pd .Index )):
574+ cols_to_style = [cols_to_style ]
575+ if not all (col in self .columns for col in cols_to_style ):
576+ raise KeyError ("one of the columns in {} wasn't found" .format (cols_to_style ))
577+
571578 if style_index_header :
572579 self ._index_header_style = styler_obj
573580
574- for column in self . data_df . columns :
575- column .style = styler_obj
581+ for column in cols_to_style :
582+ self . columns [ self . columns . get_loc ( column )] .style = styler_obj
576583 self ._has_custom_headers_style = True
577584 return self
578585
@@ -680,7 +687,7 @@ def rename(self, columns=None, inplace=False):
680687 if old_col_name in sf ._columns_width })
681688 return sf
682689
683- def style_alternate_rows (self , styles ):
690+ def style_alternate_rows (self , styles , ** kwargs ):
684691 """Applies the provided styles to rows in an alternating manner.
685692
686693 :param list|tuple|set styles: styles to apply
@@ -690,7 +697,7 @@ def style_alternate_rows(self, styles):
690697 num_of_styles = len (styles )
691698 split_indexes = (self .index [i ::num_of_styles ] for i in range (num_of_styles ))
692699 for i , indexes in enumerate (split_indexes ):
693- self .apply_style_by_indexes (indexes , styles [i ])
700+ self .apply_style_by_indexes (indexes , styles [i ], ** kwargs )
694701 return self
695702
696703 def add_color_scale_conditional_formatting (self , start_type , start_value , start_color , end_type , end_value , end_color ,
0 commit comments