I'm having trouble writing the entries of a pandas dataframe to a stringbuffer.
It's possible to initialize a dataframe by passing a stringbuffer to the read_csv function.
In [80]: buf = StringIO('a,b\n1,2\n')
In [81]: df = pandas.read_csv(buf)
In [82]: df
Out[82]:
a b
0 1 2
To do the opposite is not straight forward as the DataFrame.to_csv function only accepts a string file path.
Is there any good reason for this behaviour? What's the best way to serialize a pandas DataFrame without storing the contents on disk first?