Writing pandas DataFrame to Excel with different formats for different columns

后端 未结 2 1029
轮回少年
轮回少年 2021-02-04 18:33

I am trying to write a pandas DataFrame to an .xlsx file where different numerical columns would have different formats. For example, some would show o

2条回答
  •  北荒
    北荒 (楼主)
    2021-02-04 19:27

    As you rightly point out applying formats to individual cells is extremely inefficient.

    openpyxl 2.4 includes native support for Pandas Dataframes and named styles.

    https://openpyxl.readthedocs.io/en/latest/changes.html#id7

提交回复
热议问题