Skip to content

Commit 6895e26

Browse files
lukemanleyphofl
authored andcommitted
DEPR: enforce passing non boolean sort in concat (pandas-dev#49472)
enforce deprecation non boolean sort in concat
1 parent 6b684d8 commit 6895e26

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

doc/source/whatsnew/v2.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ Removal of prior version deprecations/changes
192192
- Enforced deprecation disallowing unit-less "datetime64" dtype in :meth:`Series.astype` and :meth:`DataFrame.astype` (:issue:`47844`)
193193
- 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`)
194194
- 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`)
195+
- Enforced deprecation disallowing passing non boolean argument to sort in :func:`concat` (:issue:`44629`)
195196
- Removed Date parser functions :func:`~pandas.io.date_converters.parse_date_time`,
196197
:func:`~pandas.io.date_converters.parse_date_fields`, :func:`~pandas.io.date_converters.parse_all_fields`
197198
and :func:`~pandas.io.date_converters.generic_parser` (:issue:`24518`)

pandas/core/reshape/concat.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
cast,
1515
overload,
1616
)
17-
import warnings
1817

1918
import numpy as np
2019

@@ -24,7 +23,6 @@
2423
HashableT,
2524
)
2625
from pandas.util._decorators import cache_readonly
27-
from pandas.util._exceptions import find_stack_level
2826

2927
from pandas.core.dtypes.concat import concat_compat
3028
from pandas.core.dtypes.generic import (
@@ -551,11 +549,8 @@ def __init__(
551549
self.levels = levels
552550

553551
if not is_bool(sort):
554-
warnings.warn(
555-
"Passing non boolean values for sort is deprecated and "
556-
"will error in a future version!",
557-
FutureWarning,
558-
stacklevel=find_stack_level(),
552+
raise ValueError(
553+
f"The 'sort' keyword only accepts boolean values; {sort} was passed."
559554
)
560555
self.sort = sort
561556

pandas/tests/reshape/concat/test_sort.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import numpy as np
2+
import pytest
23

34
import pandas as pd
45
from pandas import DataFrame
@@ -109,8 +110,9 @@ def test_concat_frame_with_sort_false(self):
109110
)
110111
tm.assert_frame_equal(result, expected)
111112

112-
def test_concat_sort_none_warning(self):
113+
def test_concat_sort_none_raises(self):
113114
# GH#41518
114115
df = DataFrame({1: [1, 2], "a": [3, 4]})
115-
with tm.assert_produces_warning(FutureWarning, match="sort"):
116+
msg = "The 'sort' keyword only accepts boolean values; None was passed."
117+
with pytest.raises(ValueError, match=msg):
116118
pd.concat([df, df], sort=None)

0 commit comments

Comments
 (0)