-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
API DesignCompatpandas objects compatability with Numpy or Python functionspandas objects compatability with Numpy or Python functionsIO DataIO issues that don't fit into a more specific labelIO issues that don't fit into a more specific label
Milestone
Description
Sometimes pickle files saved in Python v3.x are needed to read in Python v2.x. It would be nice if one can easily set pickle protocol version in to_pickle()
.
It can be done with the following little changes:
In file /pandas/io/pickle.py
:
def to_pickle(obj, path, protocol=pkl.HIGHEST_PROTOCOL):
"""
Pickle (serialize) object to input file path
Parameters
----------
obj : any object
path : string
File path
"""
with open(path, 'wb') as f:
pkl.dump(obj, f, protocol=protocol)
In file /pandas/core/generic.py
:
def to_pickle(self, path, protocol):
"""
Pickle (serialize) object to input file path.
Parameters
----------
path : string
File path
"""
from pandas.io.pickle import to_pickle
return to_pickle(self, path, protocol)
Metadata
Metadata
Assignees
Labels
API DesignCompatpandas objects compatability with Numpy or Python functionspandas objects compatability with Numpy or Python functionsIO DataIO issues that don't fit into a more specific labelIO issues that don't fit into a more specific label