Skip to content

DEP: Enforce deprecation of squeeze in read_excel #51481

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

Merged
merged 3 commits into from
Feb 19, 2023
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v2.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,7 @@ Removal of prior version deprecations/changes
- Removed argument ``is_copy`` from :meth:`DataFrame.take` and :meth:`Series.take` (:issue:`30615`)
- Removed argument ``kind`` from :meth:`Index.get_slice_bound`, :meth:`Index.slice_indexer` and :meth:`Index.slice_locs` (:issue:`41378`)
- Removed arguments ``prefix``, ``squeeze``, ``error_bad_lines`` and ``warn_bad_lines`` from :func:`read_csv` (:issue:`40413`, :issue:`43427`)
- Removed arguments ``squeeze`` from :func:`read_excel` (:issue:`43427`)
- Removed argument ``datetime_is_numeric`` from :meth:`DataFrame.describe` and :meth:`Series.describe` as datetime data will always be summarized as numeric data (:issue:`34798`)
- Disallow passing list ``key`` to :meth:`Series.xs` and :meth:`DataFrame.xs`, pass a tuple instead (:issue:`41789`)
- Disallow subclass-specific keywords (e.g. "freq", "tz", "names", "closed") in the :class:`Index` constructor (:issue:`38597`)
Expand Down
23 changes: 4 additions & 19 deletions pandas/io/excel/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,6 @@
column if the callable returns ``True``.

Returns a subset of the columns according to behavior above.
squeeze : bool, default False
If the parsed data only contains one column then return a Series.

.. deprecated:: 1.4.0
Append ``.squeeze("columns")`` to the call to ``read_excel`` to squeeze
the data.
dtype : Type name or dict of column -> type, default None
Data type for data or columns. E.g. {{'a': np.float64, 'b': np.int32}}
Use `object` to preserve data as stored in Excel and not interpret dtype.
Expand Down Expand Up @@ -383,7 +377,6 @@ def read_excel(
| Sequence[str]
| Callable[[str], bool]
| None = ...,
squeeze: bool | None = ...,
dtype: DtypeArg | None = ...,
engine: Literal["xlrd", "openpyxl", "odf", "pyxlsb"] | None = ...,
converters: dict[str, Callable] | dict[int, Callable] | None = ...,
Expand Down Expand Up @@ -423,7 +416,6 @@ def read_excel(
| Sequence[str]
| Callable[[str], bool]
| None = ...,
squeeze: bool | None = ...,
dtype: DtypeArg | None = ...,
engine: Literal["xlrd", "openpyxl", "odf", "pyxlsb"] | None = ...,
converters: dict[str, Callable] | dict[int, Callable] | None = ...,
Expand Down Expand Up @@ -463,7 +455,6 @@ def read_excel(
| Sequence[str]
| Callable[[str], bool]
| None = None,
squeeze: bool | None = None,
dtype: DtypeArg | None = None,
engine: Literal["xlrd", "openpyxl", "odf", "pyxlsb"] | None = None,
converters: dict[str, Callable] | dict[int, Callable] | None = None,
Expand Down Expand Up @@ -508,7 +499,6 @@ def read_excel(
names=names,
index_col=index_col,
usecols=usecols,
squeeze=squeeze,
dtype=dtype,
converters=converters,
true_values=true_values,
Expand Down Expand Up @@ -716,7 +706,6 @@ def parse(
names=None,
index_col: int | Sequence[int] | None = None,
usecols=None,
squeeze: bool | None = None,
dtype: DtypeArg | None = None,
true_values: Iterable[Hashable] | None = None,
false_values: Iterable[Hashable] | None = None,
Expand Down Expand Up @@ -875,7 +864,6 @@ def parse(
header=header,
index_col=index_col,
has_index_names=has_index_names,
squeeze=squeeze,
dtype=dtype,
true_values=true_values,
false_values=false_values,
Expand All @@ -897,11 +885,10 @@ def parse(

output[asheetname] = parser.read(nrows=nrows)

if not squeeze or isinstance(output[asheetname], DataFrame):
if header_names:
output[asheetname].columns = output[
asheetname
].columns.set_names(header_names)
if header_names:
output[asheetname].columns = output[asheetname].columns.set_names(
header_names
)

except EmptyDataError:
# No Data, return an empty DataFrame
Expand Down Expand Up @@ -1545,7 +1532,6 @@ def parse(
names=None,
index_col: int | Sequence[int] | None = None,
usecols=None,
squeeze: bool | None = None,
converters=None,
true_values: Iterable[Hashable] | None = None,
false_values: Iterable[Hashable] | None = None,
Expand Down Expand Up @@ -1578,7 +1564,6 @@ def parse(
names=names,
index_col=index_col,
usecols=usecols,
squeeze=squeeze,
converters=converters,
true_values=true_values,
false_values=false_values,
Expand Down