Printing to CSV file with automatic width
Is there any way in Pandas to write a DataFrame to a csv file where the
column widths are automatically adjusted? (i.e. akin to what Pandas does
when printing a DataFrame to the screen)
At the moment if I do
df.to_csv(string_buf, sep = ' ', Index=False)
print(string_buf.getvalue())
I get:
column1 column2 column3
0 4 james matching68 -100
1 44 george foo -500
2 14 jason trinitron -400
3 1 tom trinitron -400
4 1 lukas esp -100
By the way, It's also strange that it prints the Index even though I
explicitly disabled it.
No comments:
Post a Comment