pandas 1.4.2

ParametersReturns
findall(self, pat, flags=0)

Equivalent to applying re.findall to all the elements in the Series/Index.

Parameters

pat : str

Pattern or regular expression.

flags : int, default 0

Flags from re module, e.g. :None:None:`re.IGNORECASE` (default is 0, which means no flags).

Returns

Series/Index of lists of strings

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

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

See Also

count

Count occurrences of pattern or regular expression in each string of the Series/Index.

extractall

For each string in the Series, extract groups from all matches of regular expression and return a DataFrame with one row for each match and one column for each group.

re.findall

The equivalent re function to all non-overlapping matches of pattern or regular expression in string, as a list of strings.

Examples

This example is valid syntax, but we were not able to check execution
>>> s = pd.Series(['Lion', 'Monkey', 'Rabbit'])

The search for the pattern 'Monkey' returns one match:

This example is valid syntax, but we were not able to check execution
>>> s.str.findall('Monkey')
0          []
1    [Monkey]
2          []
dtype: object

On the other hand, the search for the pattern 'MONKEY' doesn't return any match:

This example is valid syntax, but we were not able to check execution
>>> s.str.findall('MONKEY')
0    []
1    []
2    []
dtype: object

Flags can be added to the pattern or regular expression. For instance, to find the pattern 'MONKEY' ignoring the case:

This example is valid syntax, but we were not able to check execution
>>> import re
... s.str.findall('MONKEY', flags=re.IGNORECASE) 0 [] 1 [Monkey] 2 [] dtype: object

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

This example is valid syntax, but we were not able to check execution
>>> s.str.findall('on')
0    [on]
1    [on]
2      []
dtype: object

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

This example is valid syntax, but we were not able to check execution
>>> s.str.findall('on$')
0    [on]
1      []
2      []
dtype: object

If the pattern is found more than once in the same string, then a list of multiple strings is returned:

This example is valid syntax, but we were not able to check execution
>>> s.str.findall('b')
0        []
1        []
2    [b, b]
dtype: object
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/strings/accessor.py#2345
type: <class 'function'>
Commit: