Pandas: [Feature Request] read_pickle and to_pickle Optionally Read/Return Strings Similar to Pickle's dumps and loads

Created on 31 Aug 2017  路  1Comment  路  Source: pandas-dev/pandas

Unless I'm mistaken there's no official way of directly getting a string representation of a DataFrame. I was using cPickle's dumps and loads functions for this, but upgrading from 0.19 to 0.20 broke things. Yes, I could use Pandas' read_pickle and to_pickle functions as they are now and use the hard disk as an intermediate step, but this would hurt performance and seems unnecessarily roundabout. Having read_pickle and to_pickle optionally work with a string similar to cPickle's dumps and loads functions would be quite straightforward, no?

Duplicate IO Data

Most helpful comment

duplicate of #5924 - never really settled on an API, feel free to comment there.

If you want want work with strings today you can use StringIO/BytesIO

from io import BytesIO
buf = BytesIO()
df.to_pickle(buf)

buf.seek(0)

df = pd.read_pickle(buf)

>All comments

duplicate of #5924 - never really settled on an API, feel free to comment there.

If you want want work with strings today you can use StringIO/BytesIO

from io import BytesIO
buf = BytesIO()
df.to_pickle(buf)

buf.seek(0)

df = pd.read_pickle(buf)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ebran picture ebran  路  3Comments

idanivanov picture idanivanov  路  3Comments

nathanielatom picture nathanielatom  路  3Comments

BDannowitz picture BDannowitz  路  3Comments

Ashutosh-Srivastav picture Ashutosh-Srivastav  路  3Comments