我正在编写一个脚本,其中我希望输出为具有自动调整的列宽的Excel工作表。此外,我希望索引列的标题出现。
现在,我运行脚本,并在Excel工作表中填充自动调整的列宽,但是没有出现索引列的标题。有没有快速 解决这个问题?
for type in tickers:
df5 = pd.DataFrame(df4.diff(periods=1, axis=0))
frames = [df4.iloc[-2,:],df4.iloc[-1,:],df5.iloc[-1,:]]
df6 = pd.concat(frames, axis=1, ignore_index=True)
df6 = round(df6, 2)
df6.columns = ["Last Week ($mm/bp)", "This Week ($mm/bp)", "Change ($mm/bp)"]
df6.index.name = "{}".format(type)
df6 = df6.reindex(index = ["ED1 Comdty", "TU1 Comdty", "FV1 Comdty", "TY1 Comdty", "UXY1 Comdty", "US1 Comdty", "WN1 Comdty", "Total"])
sf = StyleFrame(df6)
sf.to_excel(writer, sheet_name=type, index=True)
writer.save()