Skip to content

Commit 492c5e0

Browse files
authored
DOC: re-use storage_options (#37953)
1 parent 73a5213 commit 492c5e0

File tree

12 files changed

+154
-203
lines changed

12 files changed

+154
-203
lines changed

pandas/core/frame.py

+16-25
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
)
119119
from pandas.core.dtypes.missing import isna, notna
120120

121-
from pandas.core import algorithms, common as com, nanops, ops
121+
from pandas.core import algorithms, common as com, generic, nanops, ops
122122
from pandas.core.accessor import CachedAccessor
123123
from pandas.core.aggregation import (
124124
aggregate,
@@ -2066,6 +2066,7 @@ def _from_arrays(
20662066
)
20672067
return cls(mgr)
20682068

2069+
@doc(storage_options=generic._shared_docs["storage_options"])
20692070
@deprecate_kwarg(old_arg_name="fname", new_arg_name="path")
20702071
def to_stata(
20712072
self,
@@ -2118,7 +2119,7 @@ def to_stata(
21182119
variable_labels : dict
21192120
Dictionary containing columns as keys and variable labels as
21202121
values. Each label must be 80 characters or smaller.
2121-
version : {114, 117, 118, 119, None}, default 114
2122+
version : {{114, 117, 118, 119, None}}, default 114
21222123
Version to use in the output dta file. Set to None to let pandas
21232124
decide between 118 or 119 formats depending on the number of
21242125
columns in the frame. Version 114 can be read by Stata 10 and
@@ -2147,23 +2148,17 @@ def to_stata(
21472148
compression : str or dict, default 'infer'
21482149
For on-the-fly compression of the output dta. If string, specifies
21492150
compression mode. If dict, value at key 'method' specifies
2150-
compression mode. Compression mode must be one of {'infer', 'gzip',
2151-
'bz2', 'zip', 'xz', None}. If compression mode is 'infer' and
2151+
compression mode. Compression mode must be one of {{'infer', 'gzip',
2152+
'bz2', 'zip', 'xz', None}}. If compression mode is 'infer' and
21522153
`fname` is path-like, then detect compression from the following
21532154
extensions: '.gz', '.bz2', '.zip', or '.xz' (otherwise no
2154-
compression). If dict and compression mode is one of {'zip',
2155-
'gzip', 'bz2'}, or inferred as one of the above, other entries
2155+
compression). If dict and compression mode is one of {{'zip',
2156+
'gzip', 'bz2'}}, or inferred as one of the above, other entries
21562157
passed as additional compression options.
21572158
21582159
.. versionadded:: 1.1.0
21592160
2160-
storage_options : dict, optional
2161-
Extra options that make sense for a particular storage connection, e.g.
2162-
host, port, username, password, etc., if using a URL that will
2163-
be parsed by ``fsspec``, e.g., starting "s3://", "gcs://". An error
2164-
will be raised if providing this argument with a local path or
2165-
a file-like buffer. See the fsspec and backend storage implementation
2166-
docs for the set of allowed keys and values.
2161+
{storage_options}
21672162
21682163
.. versionadded:: 1.2.0
21692164
@@ -2186,9 +2181,9 @@ def to_stata(
21862181
21872182
Examples
21882183
--------
2189-
>>> df = pd.DataFrame({'animal': ['falcon', 'parrot', 'falcon',
2184+
>>> df = pd.DataFrame({{'animal': ['falcon', 'parrot', 'falcon',
21902185
... 'parrot'],
2191-
... 'speed': [350, 18, 361, 15]})
2186+
... 'speed': [350, 18, 361, 15]}})
21922187
>>> df.to_stata('animals.dta') # doctest: +SKIP
21932188
"""
21942189
if version not in (114, 117, 118, 119, None):
@@ -2255,6 +2250,7 @@ def to_feather(self, path: FilePathOrBuffer[AnyStr], **kwargs) -> None:
22552250
@doc(
22562251
Series.to_markdown,
22572252
klass=_shared_doc_kwargs["klass"],
2253+
storage_options=_shared_docs["storage_options"],
22582254
examples="""Examples
22592255
--------
22602256
>>> df = pd.DataFrame(
@@ -2307,6 +2303,7 @@ def to_markdown(
23072303
handles.handle.writelines(result)
23082304
return None
23092305

2306+
@doc(storage_options=generic._shared_docs["storage_options"])
23102307
@deprecate_kwarg(old_arg_name="fname", new_arg_name="path")
23112308
def to_parquet(
23122309
self,
@@ -2340,12 +2337,12 @@ def to_parquet(
23402337
23412338
Previously this was "fname"
23422339
2343-
engine : {'auto', 'pyarrow', 'fastparquet'}, default 'auto'
2340+
engine : {{'auto', 'pyarrow', 'fastparquet'}}, default 'auto'
23442341
Parquet library to use. If 'auto', then the option
23452342
``io.parquet.engine`` is used. The default ``io.parquet.engine``
23462343
behavior is to try 'pyarrow', falling back to 'fastparquet' if
23472344
'pyarrow' is unavailable.
2348-
compression : {'snappy', 'gzip', 'brotli', None}, default 'snappy'
2345+
compression : {{'snappy', 'gzip', 'brotli', None}}, default 'snappy'
23492346
Name of the compression to use. Use ``None`` for no compression.
23502347
index : bool, default None
23512348
If ``True``, include the dataframe's index(es) in the file output.
@@ -2365,13 +2362,7 @@ def to_parquet(
23652362
23662363
.. versionadded:: 0.24.0
23672364
2368-
storage_options : dict, optional
2369-
Extra options that make sense for a particular storage connection, e.g.
2370-
host, port, username, password, etc., if using a URL that will
2371-
be parsed by ``fsspec``, e.g., starting "s3://", "gcs://". An error
2372-
will be raised if providing this argument with a local path or
2373-
a file-like buffer. See the fsspec and backend storage implementation
2374-
docs for the set of allowed keys and values.
2365+
{storage_options}
23752366
23762367
.. versionadded:: 1.2.0
23772368
@@ -2398,7 +2389,7 @@ def to_parquet(
23982389
23992390
Examples
24002391
--------
2401-
>>> df = pd.DataFrame(data={'col1': [1, 2], 'col2': [3, 4]})
2392+
>>> df = pd.DataFrame(data={{'col1': [1, 2], 'col2': [3, 4]}})
24022393
>>> df.to_parquet('df.parquet.gzip',
24032394
... compression='gzip') # doctest: +SKIP
24042395
>>> pd.read_parquet('df.parquet.gzip') # doctest: +SKIP

0 commit comments

Comments
 (0)