Python: fastest way to write pandas DataFrame to Excel on multiple sheets

后端 未结 2 1396
眼角桃花
眼角桃花 2020-12-09 11:59

I need to export 24 pandas data frames ( 140 columns x 400 rows) to Excel, each into a different sheet.

I am using pandas’<

2条回答
  •  生来不讨喜
    2020-12-09 12:27

    For what it's worth, this is how I format the output in xlwt. The documentation is (or at least was) pretty spotty so I had to guess most of this!

    import xlwt
    
    style = xlwt.XFStyle()
    style.font.name = 'Courier'
    style.font.height = 180
    style.num_format_str = '#,##0'
    
    # ws0 is a worksheet
    ws0.write( row, col, value, style )
    

    Also, I believe I duplicated your error message when attempting to format the resulting spreadsheet in excel (office 2010 version). It's weird, but some of the drop down tool bar format options work and some don't. But it looks like they all work fine if I go to "format cells" via a right click.

提交回复
热议问题