From d6027b55527e9f256dab3a31c8c1f845f9e7c3e0 Mon Sep 17 00:00:00 2001 From: Joseph Wagner Date: Thu, 27 Oct 2016 21:18:22 -0400 Subject: [PATCH] Added optional pickle protocol version argument to pandas.to_pcikle() :issue:'14488' --- pandas/core/generic.py | 4 ++-- pandas/io/pickle.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 037ab900e6150..c7548ab0ffd4f 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -1200,7 +1200,7 @@ def to_sql(self, name, con, flavor=None, schema=None, if_exists='fail', if_exists=if_exists, index=index, index_label=index_label, chunksize=chunksize, dtype=dtype) - def to_pickle(self, path): + def to_pickle(self, path, protocol): """ Pickle (serialize) object to input file path. @@ -1210,7 +1210,7 @@ def to_pickle(self, path): File path """ from pandas.io.pickle import to_pickle - return to_pickle(self, path) + return to_pickle(self, path, protocol) def to_clipboard(self, excel=None, sep=None, **kwargs): """ diff --git a/pandas/io/pickle.py b/pandas/io/pickle.py index 2358c296f782e..d65687f08731f 100644 --- a/pandas/io/pickle.py +++ b/pandas/io/pickle.py @@ -6,7 +6,7 @@ from pandas.types.common import is_datetime64_dtype, _NS_DTYPE -def to_pickle(obj, path): +def to_pickle(obj, path, protocol=pkl.HIGHEST_PROTOCOL): """ Pickle (serialize) object to input file path @@ -17,7 +17,7 @@ def to_pickle(obj, path): File path """ with open(path, 'wb') as f: - pkl.dump(obj, f, protocol=pkl.HIGHEST_PROTOCOL) + pkl.dump(obj, f, protocol=protocol) def read_pickle(path):