def _str_extract_frame(arr, pat, flags=<NUM_LIT:0>):
from pandas import DataFrame<EOL>regex = re.compile(pat, flags=flags)<EOL>groups_or_na = _groups_or_na_fun(regex)<EOL>names = dict(zip(regex.groupindex.values(), regex.groupindex.keys()))<EOL>columns = [names.get(<NUM_LIT:1> + i, i) for i in range(regex.groups)]<EOL>if len(arr) == <NUM_LIT:0>:<EOL><INDENT>return DataFrame(columns=columns, dtype=object)<EOL><DEDENT>try:<EOL><INDENT>result_index = arr.index<EOL><DEDENT>except AttributeError:<EOL><INDENT>result_index = None<EOL><DEDENT>return DataFrame(<EOL>[groups_or_na(val) for val in arr],<EOL>columns=columns,<EOL>index=result_index,<EOL>dtype=object)<EOL>
For each subject string in the Series, extract groups from the
first match of regular expression pat. This function is called from
str_extract(expand=True), and always returns a DataFrame.