-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Storage options #35381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Storage options #35381
Changes from all commits
3a54dde
f0922c4
e549f8d
e8540c4
0034bff
19f041d
f9e1e69
7f69afe
cc0e4c3
e356e93
c7170dd
b96778d
1dc41b1
d882984
f1e455d
c88b75f
58481a4
704770b
1b8637e
bbcef17
a18686c
fa656cb
e8d5312
a79a274
97c7263
e99f8ed
23f4fc4
38a8330
32cf204
682e9e5
f7f086c
b5138f0
afdc030
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,20 @@ including other versions of pandas. | |
Enhancements | ||
~~~~~~~~~~~~ | ||
|
||
Passing arguments to fsspec backends | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
Many read/write functions have acquired the ``storage_options`` optional argument, | ||
to pass a dictionary of parameters to the storage backend. This allows, for | ||
example, for passing credentials to S3 and GCS storage. The details of what | ||
parameters can be passed to which backends can be found in the documentation | ||
jreback marked this conversation as resolved.
Show resolved
Hide resolved
|
||
of the individual storage backends (detailed from the fsspec docs for | ||
`builtin implementations`_ and linked to `external ones`_). See | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are these referenced in io.rst (more important that they are there), ok if they are here as well (but not really necessary) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I phrased it a bit differently (one general link, one specific instead of two specific) - I'll make the two places more similar. |
||
Section :ref:`io.remote`. | ||
|
||
.. _builtin implementations: https://filesystem-spec.readthedocs.io/en/latest/api.html#built-in-implementations | ||
.. _external ones: https://filesystem-spec.readthedocs.io/en/latest/api.html#other-known-implementations | ||
|
||
.. _whatsnew_120.binary_handle_to_csv: | ||
|
||
Support for binary file handles in ``to_csv`` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
Label, | ||
Level, | ||
Renamer, | ||
StorageOptions, | ||
TimedeltaConvertibleTypes, | ||
TimestampConvertibleTypes, | ||
ValueKeyFunc, | ||
|
@@ -2042,6 +2043,7 @@ def to_json( | |
compression: Optional[str] = "infer", | ||
index: bool_t = True, | ||
indent: Optional[int] = None, | ||
storage_options: StorageOptions = None, | ||
) -> Optional[str]: | ||
""" | ||
Convert the object to a JSON string. | ||
|
@@ -2125,6 +2127,16 @@ def to_json( | |
|
||
.. versionadded:: 1.0.0 | ||
|
||
storage_options : dict, optional | ||
Extra options that make sense for a particular storage connection, e.g. | ||
host, port, username, password, etc., if using a URL that will | ||
be parsed by ``fsspec``, e.g., starting "s3://", "gcs://". An error | ||
will be raised if providing this argument with a local path or | ||
a file-like buffer. See the fsspec and backend storage implementation | ||
docs for the set of allowed keys and values | ||
|
||
.. versionadded:: 1.2.0 | ||
|
||
Returns | ||
------- | ||
None or str | ||
|
@@ -2303,6 +2315,7 @@ def to_json( | |
compression=compression, | ||
index=index, | ||
indent=indent, | ||
storage_options=storage_options, | ||
) | ||
|
||
def to_hdf( | ||
|
@@ -2617,6 +2630,7 @@ def to_pickle( | |
path, | ||
compression: Optional[str] = "infer", | ||
protocol: int = pickle.HIGHEST_PROTOCOL, | ||
storage_options: StorageOptions = None, | ||
) -> None: | ||
""" | ||
Pickle (serialize) object to file. | ||
|
@@ -2637,6 +2651,16 @@ def to_pickle( | |
|
||
.. [1] https://docs.python.org/3/library/pickle.html. | ||
|
||
storage_options : dict, optional | ||
Extra options that make sense for a particular storage connection, e.g. | ||
host, port, username, password, etc., if using a URL that will | ||
be parsed by ``fsspec``, e.g., starting "s3://", "gcs://". An error | ||
will be raised if providing this argument with a local path or | ||
a file-like buffer. See the fsspec and backend storage implementation | ||
docs for the set of allowed keys and values | ||
|
||
.. versionadded:: 1.2.0 | ||
|
||
See Also | ||
-------- | ||
read_pickle : Load pickled pandas object (or any object) from file. | ||
|
@@ -2670,7 +2694,13 @@ def to_pickle( | |
""" | ||
from pandas.io.pickle import to_pickle | ||
|
||
to_pickle(self, path, compression=compression, protocol=protocol) | ||
to_pickle( | ||
self, | ||
path, | ||
compression=compression, | ||
protocol=protocol, | ||
storage_options=storage_options, | ||
) | ||
|
||
def to_clipboard( | ||
self, excel: bool_t = True, sep: Optional[str] = None, **kwargs | ||
|
@@ -3015,6 +3045,7 @@ def to_csv( | |
escapechar: Optional[str] = None, | ||
decimal: Optional[str] = ".", | ||
errors: str = "strict", | ||
storage_options: StorageOptions = None, | ||
) -> Optional[str]: | ||
r""" | ||
Write object to a comma-separated values (csv) file. | ||
|
@@ -3126,6 +3157,16 @@ def to_csv( | |
|
||
.. versionadded:: 1.1.0 | ||
|
||
storage_options : dict, optional | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i wonder if there is a way to share doc-strings components for all of these i/o methods There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not aware of a way There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah i think we can do this with our shared docs infra, but out of scope for now |
||
Extra options that make sense for a particular storage connection, e.g. | ||
host, port, username, password, etc., if using a URL that will | ||
be parsed by ``fsspec``, e.g., starting "s3://", "gcs://". An error | ||
will be raised if providing this argument with a local path or | ||
a file-like buffer. See the fsspec and backend storage implementation | ||
docs for the set of allowed keys and values | ||
|
||
.. versionadded:: 1.2.0 | ||
|
||
Returns | ||
------- | ||
None or str | ||
|
@@ -3178,6 +3219,7 @@ def to_csv( | |
doublequote=doublequote, | ||
escapechar=escapechar, | ||
decimal=decimal, | ||
storage_options=storage_options, | ||
) | ||
formatter.save() | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.