cudf.core.column.string.StringMethods.findall#

StringMethods.findall(pat: str, flags: int = 0, expand: bool = True) SeriesOrIndex#

Find all occurrences of pattern or regular expression in the Series/Index.

Parameters
patstr

Pattern or regular expression.

flagsint, default 0 (no flags)

Flags to pass through to the regex engine (e.g. re.MULTILINE)

Returns
DataFrame

All non-overlapping matches of pattern or regular expression in each string of this Series/Index.

Notes

The flags parameter currently only supports re.DOTALL and re.MULTILINE.

Examples

>>> import cudf
>>> s = cudf.Series(['Lion', 'Monkey', 'Rabbit'])

The search for the pattern ‘Monkey’ returns one match:

>>> s.str.findall('Monkey')
        0
0    <NA>
1  Monkey
2    <NA>

When the pattern matches more than one string in the Series, all matches are returned:

>>> s.str.findall('on')
      0
0    on
1    on
2  <NA>

Regular expressions are supported too. For instance, the search for all the strings ending with the word ‘on’ is shown next:

>>> s.str.findall('on$')
      0
0    on
1  <NA>
2  <NA>

If the pattern is found more than once in the same string, then multiple strings are returned as columns:

>>> s.str.findall('b')
      0     1
0  <NA>  <NA>
1  <NA>  <NA>
2     b     b