问题
How can I write
df.info() to file?
I would like to include this in a sheet of the excel file where I write my df to using df.to_excel.
According to the docs (pandas.DataFrame.info) it returns a
buf : writable buffer, defaults to sys.stdout
回答1:
I would try the following:
f = open('df.info', 'w+')
df.info(buf=f)
f.close()
来源:https://stackoverflow.com/questions/35436331/how-to-save-output-from-dataframe-info-to-file-a-excel-or-text-file