I am having trouble writing pandas frame entries to stringbuffer.
You can initialize the dataframe by passing the 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]: ab 0 1 2
To do the opposite is not direct, since the DataFrame.to_csv function accepts only the path to the string file.
Are there any good reasons for this behavior? What is the best way to serialize a pandas DataFrame without first saving the contents to disk?
rezusr
source share