如何将输出从数据帧信息保存到文件excel或文本文件 [英] how to save output from dataframe info to file a excel or text file

查看:126
本文介绍了如何将输出从数据帧信息保存到文件excel或文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何写

df.info()到档案?

我想将这个包含在excel文件的表格中,我将 df 写入 df.to_excel

I would like to include this in a sheet of the excel file where I write my df to using df.to_excel.

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

According to the docs (pandas.DataFrame.info) it returns a

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

推荐答案

我会尝试以下方法:

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

df.info(buf=f)

f.close()

这篇关于如何将输出从数据帧信息保存到文件excel或文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆