在IPython显示时将完整的数据帧保存到磁盘

时间:2014-04-10 14:34:10

标签: python pandas ipython

有没有办法将DataFrame作为字符串保存到磁盘,使用IPython用来显示它的格式和对齐方式?

请注意,我想保存完整的数据帧,而不仅仅是它的摘要(即头尾)。

1 个答案:

答案 0 :(得分:3)

IPython正在显示数据框的repr

with open(filename, 'w') as f:
    f.write(repr(df))