Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions pandas/io/excel/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,13 @@

@overload
def read_excel(
io,
io: Any,
# sheet name is str or int -> DataFrame
sheet_name: str | int = ...,
*,
header: int | Sequence[int] | None = ...,
names: SequenceNotStr[Hashable] | range | None = ...,
index_col: int | str | Sequence[int] | None = ...,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing str here is incorrect, index_col can be a string.

index_col: int | Sequence[int] | None = ...,
usecols: int
| str
| Sequence[int]
Expand All @@ -375,16 +375,18 @@ def read_excel(
| None = ...,
dtype: DtypeArg | None = ...,
engine: Literal["xlrd", "openpyxl", "odf", "pyxlsb", "calamine"] | None = ...,
converters: dict[str, Callable] | dict[int, Callable] | None = ...,
converters: dict[str, Callable[..., Any]] \
| dict[int, Callable[..., Any]] \
| None = ...,
true_values: Iterable[Hashable] | None = ...,
false_values: Iterable[Hashable] | None = ...,
skiprows: Sequence[int] | int | Callable[[int], object] | None = ...,
nrows: int | None = ...,
na_values=...,
na_values: Any =...,
keep_default_na: bool = ...,
na_filter: bool = ...,
verbose: bool = ...,
parse_dates: list | dict | bool = ...,
parse_dates: list[Any] | dict[Any, Any] | bool = ...,
date_format: dict[Hashable, str] | str | None = ...,
thousands: str | None = ...,
decimal: str = ...,
Expand All @@ -397,13 +399,13 @@ def read_excel(

@overload
def read_excel(
io,
io: Any,
# sheet name is list or None -> dict[IntStrT, DataFrame]
sheet_name: list[IntStrT] | None,
*,
header: int | Sequence[int] | None = ...,
names: SequenceNotStr[Hashable] | range | None = ...,
index_col: int | str | Sequence[int] | None = ...,
index_col: int | Sequence[int] | None = ...,
usecols: int
| str
| Sequence[int]
Expand All @@ -412,16 +414,18 @@ def read_excel(
| None = ...,
dtype: DtypeArg | None = ...,
engine: Literal["xlrd", "openpyxl", "odf", "pyxlsb", "calamine"] | None = ...,
converters: dict[str, Callable] | dict[int, Callable] | None = ...,
converters: dict[str, Callable[..., Any]] \
| dict[int, Callable[..., Any]] \
| None = ...,
true_values: Iterable[Hashable] | None = ...,
false_values: Iterable[Hashable] | None = ...,
skiprows: Sequence[int] | int | Callable[[int], object] | None = ...,
nrows: int | None = ...,
na_values=...,
na_values: Any =...,
keep_default_na: bool = ...,
na_filter: bool = ...,
verbose: bool = ...,
parse_dates: list | dict | bool = ...,
parse_dates: list[Any] | dict[Any, Any] | bool = ...,
date_format: dict[Hashable, str] | str | None = ...,
thousands: str | None = ...,
decimal: str = ...,
Expand All @@ -436,12 +440,12 @@ def read_excel(
@doc(storage_options=_shared_docs["storage_options"])
@Appender(_read_excel_doc)
def read_excel(
io,
io: Any,
sheet_name: str | int | list[IntStrT] | None = 0,
*,
header: int | Sequence[int] | None = 0,
names: SequenceNotStr[Hashable] | range | None = None,
index_col: int | str | Sequence[int] | None = None,
index_col: int | Sequence[int] | None = None,
usecols: int
| str
| Sequence[int]
Expand All @@ -450,24 +454,26 @@ def read_excel(
| None = None,
dtype: DtypeArg | None = None,
engine: Literal["xlrd", "openpyxl", "odf", "pyxlsb", "calamine"] | None = None,
converters: dict[str, Callable] | dict[int, Callable] | None = None,
converters: dict[str, Callable[..., Any]] \
| dict[int, Callable[..., Any]] \
| None = None,
true_values: Iterable[Hashable] | None = None,
false_values: Iterable[Hashable] | None = None,
skiprows: Sequence[int] | int | Callable[[int], object] | None = None,
nrows: int | None = None,
na_values=None,
na_values: Any = None,
keep_default_na: bool = True,
na_filter: bool = True,
verbose: bool = False,
parse_dates: list | dict | bool = False,
parse_dates: list[Any] | dict[Any, Any] | bool = False,
date_format: dict[Hashable, str] | str | None = None,
thousands: str | None = None,
decimal: str = ".",
comment: str | None = None,
skipfooter: int = 0,
storage_options: StorageOptions | None = None,
dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default,
engine_kwargs: dict | None = None,
engine_kwargs: dict[Any, Any] | None = None,
) -> DataFrame | dict[IntStrT, DataFrame]:
check_dtype_backend(dtype_backend)
should_close = False
Expand Down Expand Up @@ -1606,7 +1612,7 @@ def __fspath__(self):

def parse(
self,
sheet_name: str | int | list[int] | list[str] | None = 0,
sheet_name: str | int | list[IntStrT] | None = 0,
header: int | Sequence[int] | None = 0,
names: SequenceNotStr[Hashable] | range | None = None,
index_col: int | Sequence[int] | None = None,
Expand All @@ -1624,7 +1630,7 @@ def parse(
skipfooter: int = 0,
dtype_backend: DtypeBackend | lib.NoDefault = lib.no_default,
**kwds,
) -> DataFrame | dict[str, DataFrame] | dict[int, DataFrame]:
) -> DataFrame | dict[IntStrT, DataFrame]:
"""
Parse specified sheet(s) into a DataFrame.

Expand Down
Loading