如何将数据框信息的输出保存到 excel 或文本文件中
how to save output from dataframe info to file a excel or text file
怎么写
df.info()
要归档?
我想将其包含在 excel 文件的 sheet 中,我在其中写入 df
以使用 df.to_excel
.
根据文档 (pandas.DataFrame.info) 它 returns a
buf :可写缓冲区,默认为sys.stdout
我会尝试以下方法:
f = open('df.info', 'w+')
df.info(buf=f)
f.close()
怎么写
df.info()
要归档?
我想将其包含在 excel 文件的 sheet 中,我在其中写入 df
以使用 df.to_excel
.
根据文档 (pandas.DataFrame.info) 它 returns a
buf :可写缓冲区,默认为sys.stdout
我会尝试以下方法:
f = open('df.info', 'w+')
df.info(buf=f)
f.close()