2
是否可以使用熊猫的Excel作家设置字体名称?熊猫`to_excel`设置字体名称
这里是我的尝试:
import pandas as pd
from pandas.io.excel import ExcelWriter
df = pd.DataFrame([[1,2,3],[4,5,6]])
writer = ExcelWriter("test.xlsx")
writer.set_font_name("Arial") # this would be ideal, but no such method exists
format = writer.book.add_format({"font_name": "Arial"})
df.to_excel(writer) # format is not applied. Need to pass `format` object somewhere
writer.close()
我在哪里可以传递xlsxwriter.format.Format
对象一旦被创造出来的?
这几乎是完美的:它的工作原理,但在所有的标题样式:我仍然得到默认的大熊猫大胆宋体,甚至与线你建议('pd.formats.format.header_style = None')。我还试图在创建编写器之前定义标题样式,但我仍然得到相同的结果。 – gozzilli
@gozzilli,它适合我。你的Pandas版本是什么? – MaxU
0.19.2在MacOSX上 – gozzilli