Skip to content

Commit 4bf0386

Browse files
committed
Added docstring for negative protocol parameter.
1 parent 04bc5c2 commit 4bf0386

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

pandas/core/generic.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1362,7 +1362,9 @@ def to_pickle(self, path, compression='infer',
13621362
default HIGHEST_PROTOCOL (Pickle module). The possible values for
13631363
this parameter depend on the version of Python. For Python 2.x,
13641364
possible values are 0, 1, 2. For Python>=3.0, 3 is a valid value.
1365-
For Python >= 3.4, 4 is a valid value.
1365+
For Python >= 3.4, 4 is a valid value.A negative value for the
1366+
protocol parameter is equivalent to setting its value to
1367+
HIGHEST_PROTOCOL.
13661368
13671369
.. versionadded:: 0.21.0
13681370

pandas/io/pickle.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ def to_pickle(obj, path, compression='infer', protocol=pkl.HIGHEST_PROTOCOL):
2525
default HIGHEST_PROTOCOL (Pickle module). The possible values for
2626
this parameter depend on the version of Python. For Python 2.x,
2727
possible values are 0, 1, 2. For Python>=3.0, 3 is a valid value.
28-
For Python >= 3.4, 4 is a valid value.
28+
For Python >= 3.4, 4 is a valid value. A negative value for the
29+
protocol parameter is equivalent to setting its value to
30+
HIGHEST_PROTOCOL.
2931
3032
.. versionadded:: 0.21.0
3133
@@ -35,6 +37,8 @@ def to_pickle(obj, path, compression='infer', protocol=pkl.HIGHEST_PROTOCOL):
3537
f, fh = _get_handle(path, 'wb',
3638
compression=inferred_compression,
3739
is_text=False)
40+
if protocol < 0:
41+
protocol = pkl.HIGHEST_PROTOCOL
3842
try:
3943
pkl.dump(obj, f, protocol=protocol)
4044
finally:

0 commit comments

Comments
 (0)