Skip to content

Commit c104a0c

Browse files
enricorotundoTomAugspurger
authored andcommitted
DOC: update file path descriptions in IO docstrings (#25164)
1 parent 0f725bf commit c104a0c

File tree

10 files changed

+105
-35
lines changed

10 files changed

+105
-35
lines changed

pandas/io/excel/_base.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,16 @@
4141
4242
Parameters
4343
----------
44-
io : str, file descriptor, pathlib.Path, ExcelFile or xlrd.Book
45-
The string could be a URL. Valid URL schemes include http, ftp, s3,
46-
gcs, and file. For file URLs, a host is expected. For instance, a local
47-
file could be /path/to/workbook.xlsx.
44+
io : str, ExcelFile, xlrd.Book, path object or file-like object
45+
Any valid string path is acceptable. The string could be a URL. Valid
46+
URL schemes include http, ftp, s3, and file. For file URLs, a host is
47+
expected. A local file could be: ``file://localhost/path/to/table.xlsx``.
48+
49+
If you want to pass in a path object, pandas accepts any ``os.PathLike``.
50+
51+
By file-like object, we refer to objects with a ``read()`` method,
52+
such as a file handler (e.g. via builtin ``open`` function)
53+
or ``StringIO``.
4854
sheet_name : str, int, list, or None, default 0
4955
Strings are used for sheet names. Integers are used in zero-indexed
5056
sheet positions. Lists of strings/integers are used to request

pandas/io/feather_format.py

+16-5
Original file line numberDiff line numberDiff line change
@@ -69,24 +69,35 @@ def to_feather(df, path):
6969
@deprecate_kwarg(old_arg_name="nthreads", new_arg_name="use_threads")
7070
def read_feather(path, columns=None, use_threads=True):
7171
"""
72-
Load a feather-format object from the file path
72+
Load a feather-format object from the file path.
7373
7474
.. versionadded 0.20.0
7575
7676
Parameters
7777
----------
78-
path : string file path, or file-like object
78+
path : str, path object or file-like object
79+
Any valid string path is acceptable. The string could be a URL. Valid
80+
URL schemes include http, ftp, s3, and file. For file URLs, a host is
81+
expected. A local file could be:
82+
``file://localhost/path/to/table.feather``.
83+
84+
If you want to pass in a path object, pandas accepts any
85+
``os.PathLike``.
86+
87+
By file-like object, we refer to objects with a ``read()`` method,
88+
such as a file handler (e.g. via builtin ``open`` function)
89+
or ``StringIO``.
7990
columns : sequence, default None
80-
If not provided, all columns are read
91+
If not provided, all columns are read.
8192
8293
.. versionadded 0.24.0
8394
nthreads : int, default 1
84-
Number of CPU threads to use when reading to pandas.DataFrame
95+
Number of CPU threads to use when reading to pandas.DataFrame.
8596
8697
.. versionadded 0.21.0
8798
.. deprecated 0.24.0
8899
use_threads : bool, default True
89-
Whether to parallelize reading using multiple threads
100+
Whether to parallelize reading using multiple threads.
90101
91102
.. versionadded 0.24.0
92103

pandas/io/html.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ def read_html(
941941
942942
Parameters
943943
----------
944-
io : str or file-like
944+
io : str, path object or file-like object
945945
A URL, a file-like object, or a raw string containing HTML. Note that
946946
lxml only accepts the http, ftp and file url protocols. If you have a
947947
URL that starts with ``'https'`` you might try removing the ``'s'``.

pandas/io/json/_json.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,18 @@ def read_json(
352352
353353
Parameters
354354
----------
355-
path_or_buf : a valid JSON string or file-like, default: None
356-
The string could be a URL. Valid URL schemes include http, ftp, s3,
357-
gcs, and file. For file URLs, a host is expected. For instance, a local
358-
file could be ``file://localhost/path/to/table.json``
359-
355+
path_or_buf : a valid JSON str, path object or file-like object
356+
Any valid string path is acceptable. The string could be a URL. Valid
357+
URL schemes include http, ftp, s3, and file. For file URLs, a host is
358+
expected. A local file could be:
359+
``file://localhost/path/to/table.json``.
360+
361+
If you want to pass in a path object, pandas accepts any
362+
``os.PathLike``.
363+
364+
By file-like object, we refer to objects with a ``read()`` method,
365+
such as a file handler (e.g. via builtin ``open`` function)
366+
or ``StringIO``.
360367
orient : string,
361368
Indication of expected JSON string format.
362369
Compatible JSON strings can be produced by ``to_json()`` with a

pandas/io/packers.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def writer(fh):
156156
def read_msgpack(path_or_buf, encoding="utf-8", iterator=False, **kwargs):
157157
"""
158158
Load msgpack pandas object from the specified
159-
file path
159+
file path.
160160
161161
.. deprecated:: 0.25.0
162162
@@ -166,7 +166,17 @@ def read_msgpack(path_or_buf, encoding="utf-8", iterator=False, **kwargs):
166166
167167
Parameters
168168
----------
169-
path_or_buf : string File path, BytesIO like or string
169+
path_or_buf : str, path object or file-like object
170+
Any valid string path is acceptable. The string could be a URL. Valid
171+
URL schemes include http, ftp, s3, and file. For file URLs, a host is
172+
expected.
173+
174+
If you want to pass in a path object, pandas accepts any
175+
``os.PathLike``.
176+
177+
By file-like object, we refer to objects with a ``read()`` method,
178+
such as a file handler (e.g. via builtin ``open`` function) or
179+
``StringIO``.
170180
encoding : Encoding for decoding msgpack str type
171181
iterator : boolean, if True, return an iterator to the unpacker
172182
(default is False)

pandas/io/parquet.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,18 @@ def read_parquet(path, engine="auto", columns=None, **kwargs):
261261
262262
Parameters
263263
----------
264-
path : string
265-
File path
264+
path : str, path object or file-like object
265+
Any valid string path is acceptable. The string could be a URL. Valid
266+
URL schemes include http, ftp, s3, and file. For file URLs, a host is
267+
expected. A local file could be:
268+
``file://localhost/path/to/table.parquet``.
269+
270+
If you want to pass in a path object, pandas accepts any
271+
``os.PathLike``.
272+
273+
By file-like object, we refer to objects with a ``read()`` method,
274+
such as a file handler (e.g. via builtin ``open`` function)
275+
or ``StringIO``.
266276
engine : {'auto', 'pyarrow', 'fastparquet'}, default 'auto'
267277
Parquet library to use. If 'auto', then the option
268278
``io.parquet.engine`` is used. The default ``io.parquet.engine``

pandas/io/parsers.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,12 @@
8585
8686
Parameters
8787
----------
88-
filepath_or_buffer : str, path object, or file-like object
88+
filepath_or_buffer : str, path object or file-like object
8989
Any valid string path is acceptable. The string could be a URL. Valid
9090
URL schemes include http, ftp, s3, and file. For file URLs, a host is
9191
expected. A local file could be: file://localhost/path/to/table.csv.
9292
93-
If you want to pass in a path object, pandas accepts either
94-
``pathlib.Path`` or ``py._path.local.LocalPath``.
93+
If you want to pass in a path object, pandas accepts any ``os.PathLike``.
9594
9695
By file-like object, we refer to objects with a ``read()`` method, such as
9796
a file handler (e.g. via builtin ``open`` function) or ``StringIO``.
@@ -728,13 +727,14 @@ def read_fwf(
728727
729728
Parameters
730729
----------
731-
filepath_or_buffer : str, path object, or file-like object
730+
filepath_or_buffer : str, path object or file-like object
732731
Any valid string path is acceptable. The string could be a URL. Valid
733732
URL schemes include http, ftp, s3, and file. For file URLs, a host is
734-
expected. A local file could be: file://localhost/path/to/table.csv.
733+
expected. A local file could be:
734+
``file://localhost/path/to/table.csv``.
735735
736-
If you want to pass in a path object, pandas accepts either
737-
``pathlib.Path`` or ``py._path.local.LocalPath``.
736+
If you want to pass in a path object, pandas accepts any
737+
``os.PathLike``.
738738
739739
By file-like object, we refer to objects with a ``read()`` method,
740740
such as a file handler (e.g. via builtin ``open`` function)

pandas/io/pytables.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,19 @@ def read_hdf(path_or_buf, key=None, mode="r", **kwargs):
289289
290290
Parameters
291291
----------
292-
path_or_buf : string, buffer or path object
293-
Path to the file to open, or an open :class:`pandas.HDFStore` object.
294-
Supports any object implementing the ``__fspath__`` protocol.
295-
This includes :class:`pathlib.Path` and py._path.local.LocalPath
296-
objects.
292+
path_or_buf : str, path object, pandas.HDFStore or file-like object
293+
Any valid string path is acceptable. The string could be a URL. Valid
294+
URL schemes include http, ftp, s3, and file. For file URLs, a host is
295+
expected. A local file could be: ``file://localhost/path/to/table.h5``.
296+
297+
If you want to pass in a path object, pandas accepts any
298+
``os.PathLike``.
299+
300+
Alternatively, pandas accepts an open :class:`pandas.HDFStore` object.
301+
302+
By file-like object, we refer to objects with a ``read()`` method,
303+
such as a file handler (e.g. via builtin ``open`` function)
304+
or ``StringIO``.
297305
298306
.. versionadded:: 0.19.0 support for pathlib, py.path.
299307
.. versionadded:: 0.21.0 support for __fspath__ protocol.

pandas/io/sas/sasreader.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,18 @@ def read_sas(
1717
1818
Parameters
1919
----------
20-
filepath_or_buffer : string or file-like object
21-
Path to the SAS file.
20+
filepath_or_buffer : str, path object or file-like object
21+
Any valid string path is acceptable. The string could be a URL. Valid
22+
URL schemes include http, ftp, s3, and file. For file URLs, a host is
23+
expected. A local file could be:
24+
``file://localhost/path/to/table.sas``.
25+
26+
If you want to pass in a path object, pandas accepts any
27+
``os.PathLike``.
28+
29+
By file-like object, we refer to objects with a ``read()`` method,
30+
such as a file handler (e.g. via builtin ``open`` function)
31+
or ``StringIO``.
2232
format : string {'xport', 'sas7bdat'} or None
2333
If None, file format is inferred from file extension. If 'xport' or
2434
'sas7bdat', uses the corresponding format.

pandas/io/stata.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,16 @@
9494
9595
Parameters
9696
----------
97-
filepath_or_buffer : string or file-like object
98-
Path to .dta file or object implementing a binary read() functions.
97+
filepath_or_buffer : str, path object or file-like object
98+
Any valid string path is acceptable. The string could be a URL. Valid
99+
URL schemes include http, ftp, s3, and file. For file URLs, a host is
100+
expected. A local file could be: ``file://localhost/path/to/table.dta``.
101+
102+
If you want to pass in a path object, pandas accepts any ``os.PathLike``.
103+
104+
By file-like object, we refer to objects with a ``read()`` method,
105+
such as a file handler (e.g. via builtin ``open`` function)
106+
or ``StringIO``.
99107
%s
100108
%s
101109
%s

0 commit comments

Comments
 (0)