diff --git a/doc/source/whatsnew/v2.0.0.rst b/doc/source/whatsnew/v2.0.0.rst index 14b4df286d989..d0a07e58a925d 100644 --- a/doc/source/whatsnew/v2.0.0.rst +++ b/doc/source/whatsnew/v2.0.0.rst @@ -191,6 +191,7 @@ Removal of prior version deprecations/changes - Enforced deprecation disallowing unit-less "datetime64" dtype in :meth:`Series.astype` and :meth:`DataFrame.astype` (:issue:`47844`) - Enforced deprecation disallowing using ``.astype`` to convert a ``datetime64[ns]`` :class:`Series`, :class:`DataFrame`, or :class:`DatetimeIndex` to timezone-aware dtype, use ``obj.tz_localize`` or ``ser.dt.tz_localize`` instead (:issue:`39258`) - Enforced deprecation disallowing using ``.astype`` to convert a timezone-aware :class:`Series`, :class:`DataFrame`, or :class:`DatetimeIndex` to timezone-naive ``datetime64[ns]`` dtype, use ``obj.tz_localize(None)`` or ``obj.tz_convert("UTC").tz_localize(None)`` instead (:issue:`39258`) +- Enforced deprecation disallowing passing non boolean argument to sort in :func:`concat` (:issue:`44629`) - Removed Date parser functions :func:`~pandas.io.date_converters.parse_date_time`, :func:`~pandas.io.date_converters.parse_date_fields`, :func:`~pandas.io.date_converters.parse_all_fields` and :func:`~pandas.io.date_converters.generic_parser` (:issue:`24518`) diff --git a/pandas/core/reshape/concat.py b/pandas/core/reshape/concat.py index 31b6209855561..5ce69d2c2ab4c 100644 --- a/pandas/core/reshape/concat.py +++ b/pandas/core/reshape/concat.py @@ -14,7 +14,6 @@ cast, overload, ) -import warnings import numpy as np @@ -24,7 +23,6 @@ HashableT, ) from pandas.util._decorators import cache_readonly -from pandas.util._exceptions import find_stack_level from pandas.core.dtypes.concat import concat_compat from pandas.core.dtypes.generic import ( @@ -551,11 +549,8 @@ def __init__( self.levels = levels if not is_bool(sort): - warnings.warn( - "Passing non boolean values for sort is deprecated and " - "will error in a future version!", - FutureWarning, - stacklevel=find_stack_level(), + raise ValueError( + f"The 'sort' keyword only accepts boolean values; {sort} was passed." ) self.sort = sort diff --git a/pandas/tests/reshape/concat/test_sort.py b/pandas/tests/reshape/concat/test_sort.py index e83880625f3d6..2724f81958893 100644 --- a/pandas/tests/reshape/concat/test_sort.py +++ b/pandas/tests/reshape/concat/test_sort.py @@ -1,4 +1,5 @@ import numpy as np +import pytest import pandas as pd from pandas import DataFrame @@ -109,8 +110,9 @@ def test_concat_frame_with_sort_false(self): ) tm.assert_frame_equal(result, expected) - def test_concat_sort_none_warning(self): + def test_concat_sort_none_raises(self): # GH#41518 df = DataFrame({1: [1, 2], "a": [3, 4]}) - with tm.assert_produces_warning(FutureWarning, match="sort"): + msg = "The 'sort' keyword only accepts boolean values; None was passed." + with pytest.raises(ValueError, match=msg): pd.concat([df, df], sort=None)