Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create nice tables in excel with Python

So i have this script that outputs a pandas dataframe which i can save to a notebook. These tables however arent professional looking and i was wondering if there was a way in pandas/excel writing modules that would allow me to add column headers to my columns , a legend, merge cells, add a title, etc.

This is what i get from python as a pandas dataframe:enter image description here

with this script:

excel_df=pd.DataFrame(closeended_all_counts).T
excel_df.columns=all_columns

writer=pd.ExcelWriter('L:\OMIZ\March_2018.xlsx',engine='xlsxwriter')
excel_df.to_excel(writer,'Final Tables')

workbook = writer.book
worksheet = writer.sheets['Final Tables']
writer.save()

whereas i need this output:

enter image description here

any documentation or modules would be amazing!

like image 767
matthewr Avatar asked Jan 17 '26 09:01

matthewr


1 Answers

Since you're looking for documentation, here you go:

https://xlsxwriter.readthedocs.io/example_tables.html?highlight=tables

like image 170
Yuca Avatar answered Jan 21 '26 09:01

Yuca



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!