Skip to content

Commit b901bfe

Browse files
committed
Added 'zip' to possible compression types in to_pickle docstring.
Moved imports to top.
1 parent 53593d0 commit b901bfe

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pandas/io/pickle.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
""" pickle compat """
22

3+
import os
4+
import tempfile
5+
import zipfile
6+
37
import numpy as np
48
from numpy.lib.format import read_array, write_array
59
from pandas.compat import BytesIO, cPickle as pkl, pickle_compat as pc, PY3
@@ -16,7 +20,7 @@ def to_pickle(obj, path, compression='infer', protocol=pkl.HIGHEST_PROTOCOL):
1620
obj : any object
1721
path : string
1822
File path
19-
compression : {'infer', 'gzip', 'bz2', 'xz', None}, default 'infer'
23+
compression : {'infer', 'gzip', 'bz2', 'xz', 'zip', None}, default 'infer'
2024
a string representing the compression to use in the output file
2125
2226
.. versionadded:: 0.20.0
@@ -42,10 +46,7 @@ def to_pickle(obj, path, compression='infer', protocol=pkl.HIGHEST_PROTOCOL):
4246
if protocol < 0:
4347
protocol = pkl.HIGHEST_PROTOCOL
4448
try:
45-
import zipfile
4649
if isinstance(f, zipfile.ZipFile):
47-
import os
48-
import tempfile
4950
tmp_file = tempfile.NamedTemporaryFile(delete=False)
5051
pkl.dump(obj, tmp_file, protocol=protocol)
5152
tmp_file.close()

0 commit comments

Comments
 (0)