亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在 Excel 中格式化 DataFrame

在 Excel 中格式化 DataFrame

翻閱古今 2022-01-11 17:55:22
總而言之,我從原始 csv 文件中生成了一些匯總統計數據。我還將此摘要保存到了excel中。我現在需要通過格式化使這份報告看起來很漂亮。我知道將 CSS 樣式應用于數據框,但無法將這些格式導出到 excel?;蛘?,我嘗試在 xlsxwriter 中使用格式化功能取得不同程度的成功。導出后有沒有辦法格式化這個數據框?out.to_excel(writer, sheet_name='Dist-Market',startrow = 3 , startcol = 3)def frmt_tbl(ws,rng):    ws.set_column(rng, 30)
查看完整描述

1 回答

?
米琪卡哇伊

TA貢獻1998條經驗 獲得超6個贊

以下對我有幫助,我認為其他人可能也會覺得它有用。


https://xlsxwriter.readthedocs.io/working_with_pandas.html


# Add some cell formats.

format1 = workbook.add_format({'num_format': '#,##0.00'})

format2 = workbook.add_format({'num_format': '0%'})


# Set the column width and format.

worksheet.set_column('B:B', 18, format1)


# Set the format but not the column width.

worksheet.set_column('C:C', None, format2)


查看完整回答
反對 回復 2022-01-11
  • 1 回答
  • 0 關注
  • 172 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號