Closed
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)