diff --git a/doc/source/whatsnew/v0.24.0.txt b/doc/source/whatsnew/v0.24.0.txt index cf12759c051fc..321561b4df6b4 100644 --- a/doc/source/whatsnew/v0.24.0.txt +++ b/doc/source/whatsnew/v0.24.0.txt @@ -518,7 +518,7 @@ Removal of prior version deprecations/changes - The ``LongPanel`` and ``WidePanel`` classes have been removed (:issue:`10892`) - Several private functions were removed from the (non-public) module ``pandas.core.common`` (:issue:`22001`) - Removal of the previously deprecated module ``pandas.core.datetools`` (:issue:`14105`, :issue:`14094`) -- +- Removal of the previously deprecated as_indexer keyword completely from ``str.match()`` (:issue:`22356`,:issue:`6581`) .. _whatsnew_0240.performance: diff --git a/pandas/core/strings.py b/pandas/core/strings.py index 07e744a6284ef..f80260d8d2779 100644 --- a/pandas/core/strings.py +++ b/pandas/core/strings.py @@ -709,7 +709,7 @@ def rep(x, r): return result -def str_match(arr, pat, case=True, flags=0, na=np.nan, as_indexer=None): +def str_match(arr, pat, case=True, flags=0, na=np.nan): """ Determine if each string matches a regular expression. @@ -722,8 +722,6 @@ def str_match(arr, pat, case=True, flags=0, na=np.nan, as_indexer=None): flags : int, default 0 (no flags) re module flags, e.g. re.IGNORECASE na : default NaN, fill value for missing values. - as_indexer - .. deprecated:: 0.21.0 Returns ------- @@ -741,17 +739,6 @@ def str_match(arr, pat, case=True, flags=0, na=np.nan, as_indexer=None): regex = re.compile(pat, flags=flags) - if (as_indexer is False) and (regex.groups > 0): - raise ValueError("as_indexer=False with a pattern with groups is no " - "longer supported. Use '.str.extract(pat)' instead") - elif as_indexer is not None: - # Previously, this keyword was used for changing the default but - # deprecated behaviour. This keyword is now no longer needed. - warnings.warn("'as_indexer' keyword was specified but is ignored " - "(match now returns a boolean indexer by default), " - "and will be removed in a future version.", - FutureWarning, stacklevel=3) - dtype = bool f = lambda x: bool(regex.match(x)) @@ -2469,9 +2456,8 @@ def contains(self, pat, case=True, flags=0, na=np.nan, regex=True): return self._wrap_result(result) @copy(str_match) - def match(self, pat, case=True, flags=0, na=np.nan, as_indexer=None): - result = str_match(self._parent, pat, case=case, flags=flags, na=na, - as_indexer=as_indexer) + def match(self, pat, case=True, flags=0, na=np.nan): + result = str_match(self._parent, pat, case=case, flags=flags, na=na) return self._wrap_result(result) @copy(str_replace) diff --git a/pandas/tests/test_strings.py b/pandas/tests/test_strings.py index 9d008dfd25c90..446df5d2e7d11 100644 --- a/pandas/tests/test_strings.py +++ b/pandas/tests/test_strings.py @@ -938,21 +938,6 @@ def test_match(self): exp = Series([True, NA, False]) tm.assert_series_equal(result, exp) - # test passing as_indexer still works but is ignored - values = Series(['fooBAD__barBAD', NA, 'foo']) - exp = Series([True, NA, False]) - with tm.assert_produces_warning(FutureWarning): - result = values.str.match('.*BAD[_]+.*BAD', as_indexer=True) - tm.assert_series_equal(result, exp) - with tm.assert_produces_warning(FutureWarning): - result = values.str.match('.*BAD[_]+.*BAD', as_indexer=False) - tm.assert_series_equal(result, exp) - with tm.assert_produces_warning(FutureWarning): - result = values.str.match('.*(BAD[_]+).*(BAD)', as_indexer=True) - tm.assert_series_equal(result, exp) - pytest.raises(ValueError, values.str.match, '.*(BAD[_]+).*(BAD)', - as_indexer=False) - # mixed mixed = Series(['aBAD_BAD', NA, 'BAD_b_BAD', True, datetime.today(), 'foo', None, 1, 2.])