Python - Change Header Color Of Dataframe And Save It To Excel File
I have a dataframe df where i want to change the header background color, apply borders and save it excel file in .xlsx extension. I have tried styleframe, some functionalities in
Solution 1:
Here is the solution using StyleFrame package that you mentioned.
import pandas as pd
from StyleFrame import StyleFrame, Styler, utils
df = pd.DataFrame({'a': [1, 2, 3], 'b': [1, 2, 3]})
sf = StyleFrame(df)
sf.apply_headers_style(styler_obj=Styler(bold=True,
bg_color=utils.colors.green,
border_type=utils.borders.medium))
sf.to_excel('output.xlsx').save()
I would recommend you to make sure that you have the lastest version of StyleFrame installed.
pip install -U styleframe
Post a Comment for "Python - Change Header Color Of Dataframe And Save It To Excel File"