7
7
8
8
from pandas ._typing import FilePathOrBuffer
9
9
10
- from pandas .io .common import (
11
- _get_handle ,
12
- get_filepath_or_buffer as _get_filepath_or_buffer ,
13
- )
10
+ from pandas .io .common import _get_handle , get_filepath_or_buffer
14
11
15
12
16
13
def to_pickle (
@@ -26,8 +23,9 @@ def to_pickle(
26
23
----------
27
24
obj : any object
28
25
Any python object.
29
- path : str
26
+ filepath_or_buffer : str, path object or file-like object
30
27
File path, URL, or buffer where the pickled object will be stored.
28
+ URL has to be either of S3 or GCS.
31
29
compression : {'infer', 'gzip', 'bz2', 'zip', 'xz', None}, default 'infer'
32
30
If 'infer' and 'path_or_url' is path-like, then detect compression from
33
31
the following extensions: '.gz', '.bz2', '.zip', or '.xz' (otherwise no
@@ -76,7 +74,7 @@ def to_pickle(
76
74
>>> import os
77
75
>>> os.remove("./dummy.pkl")
78
76
"""
79
- fp_or_buf , _ , compression , should_close = _get_filepath_or_buffer (
77
+ fp_or_buf , _ , compression , should_close = get_filepath_or_buffer (
80
78
filepath_or_buffer , compression = compression , mode = "wb"
81
79
)
82
80
if not isinstance (fp_or_buf , str ) and compression == "infer" :
@@ -110,8 +108,9 @@ def read_pickle(
110
108
111
109
Parameters
112
110
----------
113
- filepath_or_buffer : str
111
+ filepath_or_buffer : str, path object or file-like object
114
112
File path, URL, or buffer where the pickled object will be loaded from.
113
+ URL is not limited to S3 and GCS.
115
114
compression : {'infer', 'gzip', 'bz2', 'zip', 'xz', None}, default 'infer'
116
115
If 'infer' and 'path_or_url' is path-like, then detect compression from
117
116
the following extensions: '.gz', '.bz2', '.zip', or '.xz' (otherwise no
@@ -158,7 +157,7 @@ def read_pickle(
158
157
>>> import os
159
158
>>> os.remove("./dummy.pkl")
160
159
"""
161
- fp_or_buf , _ , compression , should_close = _get_filepath_or_buffer (
160
+ fp_or_buf , _ , compression , should_close = get_filepath_or_buffer (
162
161
filepath_or_buffer , compression = compression
163
162
)
164
163
if not isinstance (fp_or_buf , str ) and compression == "infer" :
0 commit comments