Skip to content

Commit 70c9003

Browse files
HyunTruthjorisvandenbossche
authored andcommitted
CLN/DEPR: removed deprecated as_indexer arg from str.match() (#22626)
1 parent 05a7229 commit 70c9003

File tree

3 files changed

+4
-33
lines changed

3 files changed

+4
-33
lines changed

doc/source/whatsnew/v0.24.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ Removal of prior version deprecations/changes
568568
- Removal of the previously deprecated module ``pandas.core.datetools`` (:issue:`14105`, :issue:`14094`)
569569
- Strings passed into :meth:`DataFrame.groupby` that refer to both column and index levels will raise a ``ValueError`` (:issue:`14432`)
570570
- :meth:`Index.repeat` and :meth:`MultiIndex.repeat` have renamed the ``n`` argument to ``repeats``(:issue:`14645`)
571-
-
571+
- Removal of the previously deprecated ``as_indexer`` keyword completely from ``str.match()`` (:issue:`22356`,:issue:`6581`)
572572

573573
.. _whatsnew_0240.performance:
574574

pandas/core/strings.py

+3-17
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ def rep(x, r):
712712
return result
713713

714714

715-
def str_match(arr, pat, case=True, flags=0, na=np.nan, as_indexer=None):
715+
def str_match(arr, pat, case=True, flags=0, na=np.nan):
716716
"""
717717
Determine if each string matches a regular expression.
718718
@@ -725,8 +725,6 @@ def str_match(arr, pat, case=True, flags=0, na=np.nan, as_indexer=None):
725725
flags : int, default 0 (no flags)
726726
re module flags, e.g. re.IGNORECASE
727727
na : default NaN, fill value for missing values.
728-
as_indexer
729-
.. deprecated:: 0.21.0
730728
731729
Returns
732730
-------
@@ -744,17 +742,6 @@ def str_match(arr, pat, case=True, flags=0, na=np.nan, as_indexer=None):
744742

745743
regex = re.compile(pat, flags=flags)
746744

747-
if (as_indexer is False) and (regex.groups > 0):
748-
raise ValueError("as_indexer=False with a pattern with groups is no "
749-
"longer supported. Use '.str.extract(pat)' instead")
750-
elif as_indexer is not None:
751-
# Previously, this keyword was used for changing the default but
752-
# deprecated behaviour. This keyword is now no longer needed.
753-
warnings.warn("'as_indexer' keyword was specified but is ignored "
754-
"(match now returns a boolean indexer by default), "
755-
"and will be removed in a future version.",
756-
FutureWarning, stacklevel=3)
757-
758745
dtype = bool
759746
f = lambda x: bool(regex.match(x))
760747

@@ -2490,9 +2477,8 @@ def contains(self, pat, case=True, flags=0, na=np.nan, regex=True):
24902477
return self._wrap_result(result)
24912478

24922479
@copy(str_match)
2493-
def match(self, pat, case=True, flags=0, na=np.nan, as_indexer=None):
2494-
result = str_match(self._parent, pat, case=case, flags=flags, na=na,
2495-
as_indexer=as_indexer)
2480+
def match(self, pat, case=True, flags=0, na=np.nan):
2481+
result = str_match(self._parent, pat, case=case, flags=flags, na=na)
24962482
return self._wrap_result(result)
24972483

24982484
@copy(str_replace)

pandas/tests/test_strings.py

-15
Original file line numberDiff line numberDiff line change
@@ -947,21 +947,6 @@ def test_match(self):
947947
exp = Series([True, NA, False])
948948
tm.assert_series_equal(result, exp)
949949

950-
# test passing as_indexer still works but is ignored
951-
values = Series(['fooBAD__barBAD', NA, 'foo'])
952-
exp = Series([True, NA, False])
953-
with tm.assert_produces_warning(FutureWarning):
954-
result = values.str.match('.*BAD[_]+.*BAD', as_indexer=True)
955-
tm.assert_series_equal(result, exp)
956-
with tm.assert_produces_warning(FutureWarning):
957-
result = values.str.match('.*BAD[_]+.*BAD', as_indexer=False)
958-
tm.assert_series_equal(result, exp)
959-
with tm.assert_produces_warning(FutureWarning):
960-
result = values.str.match('.*(BAD[_]+).*(BAD)', as_indexer=True)
961-
tm.assert_series_equal(result, exp)
962-
pytest.raises(ValueError, values.str.match, '.*(BAD[_]+).*(BAD)',
963-
as_indexer=False)
964-
965950
# mixed
966951
mixed = Series(['aBAD_BAD', NA, 'BAD_b_BAD', True, datetime.today(),
967952
'foo', None, 1, 2.])

0 commit comments

Comments
 (0)