Question

Is there any way to save a DataFrame to disk as a string, using the format and alignment that IPython uses to display it?

Note that I would like to save the full dataframe, and not just a summary (i.e. head & tail) of it.

Was it helpful?

Solution

IPython is showing the repr of the dataframe:

with open(filename, 'w') as f:
    f.write(repr(df))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top