I want to create a fixed format for ExcelWriter in Pandas which I could use in many scripts, without needing to write it everytime. I know I can create a format with:
import pandas as pd
writer = pd.ExcelWriter('demo.xlsx', engine='xlsxwriter')
workbook = writer.book
num_fmt = workbook.add_format({'num_format': '#,##0.0'})
And then use num_fmt
with:
worksheet.set_column('H:H', 8, num_fmt)
But I'm looking for a way to avoid re-defining num_fmt
in every script I write. I have a self-defined package named my_pack
that I import to every script, and I want to somehow define num_fmt
there, so I could use it like:
worksheet.set_column('H:H', 8, my_pack.num_fmt)
without defining num_fmt
in the current script.
Is that possible?