diff --git a/doc/source/whatsnew/v2.0.0.rst b/doc/source/whatsnew/v2.0.0.rst index ac7d30310be9e..df958a63c4528 100644 --- a/doc/source/whatsnew/v2.0.0.rst +++ b/doc/source/whatsnew/v2.0.0.rst @@ -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`) diff --git a/pandas/io/excel/_base.py b/pandas/io/excel/_base.py index 1f66fd036a1c6..790a31eab7c05 100644 --- a/pandas/io/excel/_base.py +++ b/pandas/io/excel/_base.py @@ -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. @@ -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 = ..., @@ -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 = ..., @@ -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, @@ -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, @@ -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, @@ -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, @@ -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 @@ -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, @@ -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,