Repository: pandas-dev/pandas

Issue:
Match can return non-boolean results yet warning suggests results are boolean
#### Code Sample, a copy-pastable example if possible

```python
In [26]: pd.Series(['a', 'b', 4]).str.match('a')
Out[26]:
0     True
1    False
2      NaN
dtype: object

In [27]: pd.Series(['a', 'b', 4]).str.match('a', as_indexer=True)
# C:\Users\username\AppData\Local\Continuum\Anaconda3\Scripts\ipython:1: FutureWarning: 'as_indexer' keyword was specified but is ignored (match now returns a boolean indexer by default), and will be removed in a future version.
Out[27]:
0     True
1    False
2      NaN
dtype: object
```
#### Problem description

The warning states that `match` (and similarly for `search`) returns a boolean indexer by default, yet that's not the case for numeric input, as the example shows.

This one caught me off guard as it caused an indexing error in a piece of code that assumed that the result of `match` could be used as a mask regardless of input types.

#### Expected Output

The output currently obtainable by letting `na=False`:

```python
In [33]: pd.Series(['a', 'b', 4]).str.contains('a', na=False)
Out[33]:
0     True
1    False
2    False
dtype: bool
```

#### Output of ``pd.show_versions()``

<details>

INSTALLED VERSIONS
------------------
commit: None
python: 3.6.5.final.0
python-bits: 64
OS: Windows
OS-release: 8.1
machine: AMD64
processor: Intel64 Family 6 Model 61 Stepping 4, Genuin
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None

pandas: 0.23.4
pytest: 3.3.2
pip: 18.0
setuptools: 38.4.0
Cython: 0.27.3
numpy: 1.13.3
scipy: 1.0.0
pyarrow: None
xarray: None
IPython: 6.2.1
sphinx: 1.6.3
patsy: 0.5.0
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.4
feather: None
matplotlib: 2.1.2
openpyxl: 2.4.9
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 1.0.2
lxml: 4.1.1
bs4: 4.6.0
html5lib: 0.9999999
sqlalchemy: 1.2.8
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

</details>



Discussion:
That keyword is slated to be removed in 0.24 https://github.com/pandas-dev/pandas/issues/6581

Could you make a PR just removing it, rather than changing the error message?
@TomAugspurger I created a PR with the removal and change of test to accomodate the change #22356 
Heh, one has to be fast around here.
maybe my search is not working properly (as this is not listed as all), but this is versionchanged in 0.21.0 on the change, hence we would remove > 0.24, @TomAugspurger ?
https://github.com/pandas-dev/pandas/issues/6581 has it listed as under (0.24 / 1.0). Not sure what that means.

Resolving patch:
diff --git a/pandas/core/strings.py b/pandas/core/strings.py
--- a/pandas/core/strings.py
+++ b/pandas/core/strings.py
@@ -712,7 +712,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.
 
@@ -725,8 +725,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
     -------
@@ -744,17 +742,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))
 
@@ -2490,9 +2477,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)


Test patch:
diff --git a/pandas/tests/test_strings.py b/pandas/tests/test_strings.py
--- a/pandas/tests/test_strings.py
+++ b/pandas/tests/test_strings.py
@@ -947,21 +947,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.])