Skip to content

Commit 592e34f

Browse files
authored
DEP: Enforce deprecation of squeeze in read_excel (#51481)
1 parent 6b45476 commit 592e34f

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

doc/source/whatsnew/v2.0.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,7 @@ Removal of prior version deprecations/changes
922922
- Removed argument ``is_copy`` from :meth:`DataFrame.take` and :meth:`Series.take` (:issue:`30615`)
923923
- Removed argument ``kind`` from :meth:`Index.get_slice_bound`, :meth:`Index.slice_indexer` and :meth:`Index.slice_locs` (:issue:`41378`)
924924
- Removed arguments ``prefix``, ``squeeze``, ``error_bad_lines`` and ``warn_bad_lines`` from :func:`read_csv` (:issue:`40413`, :issue:`43427`)
925+
- Removed arguments ``squeeze`` from :func:`read_excel` (:issue:`43427`)
925926
- 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`)
926927
- Disallow passing list ``key`` to :meth:`Series.xs` and :meth:`DataFrame.xs`, pass a tuple instead (:issue:`41789`)
927928
- Disallow subclass-specific keywords (e.g. "freq", "tz", "names", "closed") in the :class:`Index` constructor (:issue:`38597`)

pandas/io/excel/_base.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,6 @@
140140
column if the callable returns ``True``.
141141
142142
Returns a subset of the columns according to behavior above.
143-
squeeze : bool, default False
144-
If the parsed data only contains one column then return a Series.
145-
146-
.. deprecated:: 1.4.0
147-
Append ``.squeeze("columns")`` to the call to ``read_excel`` to squeeze
148-
the data.
149143
dtype : Type name or dict of column -> type, default None
150144
Data type for data or columns. E.g. {{'a': np.float64, 'b': np.int32}}
151145
Use `object` to preserve data as stored in Excel and not interpret dtype.
@@ -383,7 +377,6 @@ def read_excel(
383377
| Sequence[str]
384378
| Callable[[str], bool]
385379
| None = ...,
386-
squeeze: bool | None = ...,
387380
dtype: DtypeArg | None = ...,
388381
engine: Literal["xlrd", "openpyxl", "odf", "pyxlsb"] | None = ...,
389382
converters: dict[str, Callable] | dict[int, Callable] | None = ...,
@@ -423,7 +416,6 @@ def read_excel(
423416
| Sequence[str]
424417
| Callable[[str], bool]
425418
| None = ...,
426-
squeeze: bool | None = ...,
427419
dtype: DtypeArg | None = ...,
428420
engine: Literal["xlrd", "openpyxl", "odf", "pyxlsb"] | None = ...,
429421
converters: dict[str, Callable] | dict[int, Callable] | None = ...,
@@ -463,7 +455,6 @@ def read_excel(
463455
| Sequence[str]
464456
| Callable[[str], bool]
465457
| None = None,
466-
squeeze: bool | None = None,
467458
dtype: DtypeArg | None = None,
468459
engine: Literal["xlrd", "openpyxl", "odf", "pyxlsb"] | None = None,
469460
converters: dict[str, Callable] | dict[int, Callable] | None = None,
@@ -508,7 +499,6 @@ def read_excel(
508499
names=names,
509500
index_col=index_col,
510501
usecols=usecols,
511-
squeeze=squeeze,
512502
dtype=dtype,
513503
converters=converters,
514504
true_values=true_values,
@@ -716,7 +706,6 @@ def parse(
716706
names=None,
717707
index_col: int | Sequence[int] | None = None,
718708
usecols=None,
719-
squeeze: bool | None = None,
720709
dtype: DtypeArg | None = None,
721710
true_values: Iterable[Hashable] | None = None,
722711
false_values: Iterable[Hashable] | None = None,
@@ -875,7 +864,6 @@ def parse(
875864
header=header,
876865
index_col=index_col,
877866
has_index_names=has_index_names,
878-
squeeze=squeeze,
879867
dtype=dtype,
880868
true_values=true_values,
881869
false_values=false_values,
@@ -897,11 +885,10 @@ def parse(
897885

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

900-
if not squeeze or isinstance(output[asheetname], DataFrame):
901-
if header_names:
902-
output[asheetname].columns = output[
903-
asheetname
904-
].columns.set_names(header_names)
888+
if header_names:
889+
output[asheetname].columns = output[asheetname].columns.set_names(
890+
header_names
891+
)
905892

906893
except EmptyDataError:
907894
# No Data, return an empty DataFrame
@@ -1545,7 +1532,6 @@ def parse(
15451532
names=None,
15461533
index_col: int | Sequence[int] | None = None,
15471534
usecols=None,
1548-
squeeze: bool | None = None,
15491535
converters=None,
15501536
true_values: Iterable[Hashable] | None = None,
15511537
false_values: Iterable[Hashable] | None = None,
@@ -1578,7 +1564,6 @@ def parse(
15781564
names=names,
15791565
index_col=index_col,
15801566
usecols=usecols,
1581-
squeeze=squeeze,
15821567
converters=converters,
15831568
true_values=true_values,
15841569
false_values=false_values,

0 commit comments

Comments
 (0)