Domanda

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.

È stato utile?

Soluzione

IPython is showing the repr of the dataframe:

with open(filename, 'w') as f:
    f.write(repr(df))
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top