Series.str can be used to access the values of the series as strings and apply several methods to it. Pandas
Series.str.extractall() function is used to extract capture groups in the regex pat as columns in a DataFrame. For each subject string in the Series, extract groups from all matches of regular expression pat. When each subject string in the Series has exactly one match, extractall(pat).xs(0, level=βmatchβ) is the same as extract(pat).
Syntax: Series.str.extractall(pat, flags=0)
Parameter :
pat : Regular expression pattern with capturing groups.
flags : A re module flag, for example re.IGNORECASE.
Returns : DataFrame
Example #1: Use
Series.str.extractall() function to extract all groups from the string in the underlying data of the given series object.
Output :
π Image
Now we will use
Series.str.extractall() function to extract all groups from the strings in the given series object.
Output :
π Image
As we can see in the output, the
Series.str.extractall() function has returned a dataframe containing a column of all the extracted group.
Example #2 : Use
Series.str.extractall() function to extract all groups from the string in the underlying data of the given series object.
Output :
π Image
Now we will use
Series.str.extractall() function to extract all groups from the strings in the given series object.
Output :
π Image
As we can see in the output, the
Series.str.extractall() function has returned a dataframe containing a column of all the extracted group.