I have dataframe df_brands
and I want to format this df and export to excel-file, but I have a problem
I have df_brands
:
and I format this df:
and after this I want save this formatted df in excel-file, but this is bad:
I want to keep all formatting when I export to excel-file. Also I want fix column column width
Maybe I can export in another way? as picture maybe? but I want to save table format
When you export a "styled dataframe" (which is a different object than a simple dataframe), there are some "styles" that you will lose.
To get the styles you want in the final excel file, there are 2 ways:
Give a df to this function you will get back a styled dfs where values are centered.
NB: Your screenshots are from Jupyter. Who tell you that it's not Jupyter which is kindly adjusting the column widths for you ?
In the function below "ws" is a worksheet object. "num" indicate the columns widths i want to use