def _str_extract_noexpand(arr, pat, flags=<NUM_LIT:0>):
from pandas import DataFrame, Index<EOL>regex = re.compile(pat, flags=flags)<EOL>groups_or_na = _groups_or_na_fun(regex)<EOL>if regex.groups == <NUM_LIT:1>:<EOL><INDENT>result = np.array([groups_or_na(val)[<NUM_LIT:0>] for val in arr], dtype=object)<EOL>name = _get_single_group_name(regex)<EOL><DEDENT>else:<EOL><INDENT>if isinstance(arr, Index):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>name = None<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 arr.empty:<EOL><INDENT>result = DataFrame(columns=columns, dtype=object)<EOL><DEDENT>else:<EOL><INDENT>result = DataFrame(<EOL>[groups_or_na(val) for val in arr],<EOL>columns=columns,<EOL>index=arr.index,<EOL>dtype=object)<EOL><DEDENT><DEDENT>return result, name<EOL>
Find groups in each string in the Series using passed regular
expression. This function is called from
str_extract(expand=False), and can return Series, DataFrame, or
Index.