【问题标题】:how to save output from dataframe info to file a excel or text file如何将数据框信息的输出保存到excel或文本文件中
【发布时间】:2016-05-27 22:54:56
【问题描述】:

我该怎么写

df.info() 归档?

我想将此包含在 Excel 文件的工作表中,我将我的 df 写入使用 df.to_excel

根据文档 (pandas.DataFrame.info) 它返回一个

buf : 可写缓冲区,默认为 sys.stdout

【问题讨论】:

  • 我认为如果你将文件句柄作为参数传递给buf,那么它应该把它写出来

标签: python pandas io buffer stdout


【解决方案1】:

我会尝试以下方法:

f = open('df.info', 'w+')

df.info(buf=f)

f.close()

【讨论】:

    猜你喜欢
    • 2021-07-14
    • 2019-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-22
    • 2021-12-08
    相关资源
    最近更新 更多