Python 导出到excel时如何设置列标题?
我正在尝试更改标题标题:Python 导出到excel时如何设置列标题?,python,pandas,Python,Pandas,我正在尝试更改标题标题: columns = {} for item in df.columns.map(lambda x: {x: self._get_column_header(x)}): columns.update(item) self._set_column_style(df).to_excel(xls_writer, sheet_name=tab_config['tab_title'],
columns = {}
for item in df.columns.map(lambda x: {x: self._get_column_header(x)}):
columns.update(item)
self._set_column_style(df).to_excel(xls_writer,
sheet_name=tab_config['tab_title'],
startcol=1,
startrow=4,
index=False,
header=False,
columns=columns)
但这不是工作。
我必须仅在导出到excel时更改标题,因为\u set\u column\u style
功能使用原始标题。来自:
标题:bool或str列表,默认为True写出列名。如果给定了字符串列表,则假定它是列名的别名 您应该将所需的标题作为修改过的列名列表 列:str的序列或列表,可选 要编写的列 在这里,您将原始数据框列名按相同的顺序排列,因为它指定从原始数据框中拾取哪些列