Skip to content

Commit

Permalink
Added 'zip' to possible compression types in to_pickle docstring.
Browse files Browse the repository at this point in the history
Moved imports to top.
  • Loading branch information
Krzysztof Chomski committed Nov 14, 2017
1 parent 53593d0 commit 8903378
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pandas/io/pickle.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
""" pickle compat """

import os
import tempfile
import zipfile

import numpy as np
from numpy.lib.format import read_array, write_array
from pandas.compat import BytesIO, cPickle as pkl, pickle_compat as pc, PY3
Expand All @@ -16,7 +20,7 @@ def to_pickle(obj, path, compression='infer', protocol=pkl.HIGHEST_PROTOCOL):
obj : any object
path : string
File path
compression : {'infer', 'gzip', 'bz2', 'xz', None}, default 'infer'
compression : {'infer', 'gzip', 'bz2', 'xz', 'zip', None}, default 'infer'
a string representing the compression to use in the output file
.. versionadded:: 0.20.0
Expand All @@ -42,10 +46,7 @@ def to_pickle(obj, path, compression='infer', protocol=pkl.HIGHEST_PROTOCOL):
if protocol < 0:
protocol = pkl.HIGHEST_PROTOCOL
try:
import zipfile
if isinstance(f, zipfile.ZipFile):
import os
import tempfile
tmp_file = tempfile.NamedTemporaryFile(delete=False)
pkl.dump(obj, tmp_file, protocol=protocol)
tmp_file.close()
Expand Down

0 comments on commit 8903378

Please sign in to comment.