diff --git a/doc/source/whatsnew/v2.0.0.rst b/doc/source/whatsnew/v2.0.0.rst index c2abb70988dad..4475ee1732865 100644 --- a/doc/source/whatsnew/v2.0.0.rst +++ b/doc/source/whatsnew/v2.0.0.rst @@ -401,6 +401,7 @@ Removal of prior version deprecations/changes - Removed ``pandas.SparseSeries`` and ``pandas.SparseDataFrame``, including pickle support. (:issue:`30642`) - Enforced disallowing passing an integer ``fill_value`` to :meth:`DataFrame.shift` and :meth:`Series.shift`` with datetime64, timedelta64, or period dtypes (:issue:`32591`) - Enforced disallowing a string column label into ``times`` in :meth:`DataFrame.ewm` (:issue:`43265`) +- Enforced disallowing passing ``True`` and ``False`` into ``inclusive`` in :meth:`Series.between` in favor of ``"both"`` and ``"neither"`` respectively (:issue:`40628`) - Enforced disallowing using ``usecols`` with out of bounds indices for ``read_csv`` with ``engine="c"`` (:issue:`25623`) - Enforced disallowing the use of ``**kwargs`` in :class:`.ExcelWriter`; use the keyword argument ``engine_kwargs`` instead (:issue:`40430`) - Enforced disallowing a tuple of column labels into :meth:`.DataFrameGroupBy.__getitem__` (:issue:`30546`) diff --git a/pandas/core/series.py b/pandas/core/series.py index e069b2766c8fc..8716170594a80 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -5427,19 +5427,6 @@ def between( 3 False dtype: bool """ - # error: Non-overlapping identity check (left operand type: "Literal['both', - # 'neither', 'left', 'right']", right operand type: "Literal[False]") - if inclusive is True or inclusive is False: # type: ignore[comparison-overlap] - warnings.warn( - "Boolean inputs to the `inclusive` argument are deprecated in " - "favour of `both` or `neither`.", - FutureWarning, - stacklevel=find_stack_level(), - ) - if inclusive: - inclusive = "both" - else: - inclusive = "neither" if inclusive == "both": lmask = self >= left rmask = self <= right diff --git a/pandas/tests/series/methods/test_between.py b/pandas/tests/series/methods/test_between.py index d81017633ff76..8f4931beae589 100644 --- a/pandas/tests/series/methods/test_between.py +++ b/pandas/tests/series/methods/test_between.py @@ -38,7 +38,8 @@ def test_between_period_values(self): expected = (ser >= left) & (ser <= right) tm.assert_series_equal(result, expected) - def test_between_inclusive_string(self): # :issue:`40628` + def test_between_inclusive_string(self): + # GH 40628 series = Series(date_range("1/1/2000", periods=10)) left, right = series[[2, 7]] @@ -58,7 +59,9 @@ def test_between_inclusive_string(self): # :issue:`40628` expected = (series > left) & (series < right) tm.assert_series_equal(result, expected) - def test_between_error_args(self): # :issue:`40628` + @pytest.mark.parametrize("inclusive", ["yes", True, False]) + def test_between_error_args(self, inclusive): + # GH 40628 series = Series(date_range("1/1/2000", periods=10)) left, right = series[[2, 7]] @@ -69,16 +72,4 @@ def test_between_error_args(self): # :issue:`40628` with pytest.raises(ValueError, match=value_error_msg): series = Series(date_range("1/1/2000", periods=10)) - series.between(left, right, inclusive="yes") - - def test_between_inclusive_warning(self): - series = Series(date_range("1/1/2000", periods=10)) - left, right = series[[2, 7]] - with tm.assert_produces_warning(FutureWarning): - result = series.between(left, right, inclusive=False) - expected = (series > left) & (series < right) - tm.assert_series_equal(result, expected) - with tm.assert_produces_warning(FutureWarning): - result = series.between(left, right, inclusive=True) - expected = (series >= left) & (series <= right) - tm.assert_series_equal(result, expected) + series.between(left, right, inclusive=inclusive)