MCPcopy
hub / github.com/pandas-dev/pandas / _get_group_names

Function _get_group_names

pandas/core/strings/accessor.py:4822–4844  ·  view source on GitHub ↗

Get named groups from compiled regex. Unnamed groups are numbered. Parameters ---------- regex : compiled regex Returns ------- list of column labels

(regex: re.Pattern)

Source from the content-addressed store, hash-verified

4820
4821
4822def _get_group_names(regex: re.Pattern) -> list[Hashable] | range:
4823 """
4824 Get named groups from compiled regex.
4825
4826 Unnamed groups are numbered.
4827
4828 Parameters
4829 ----------
4830 regex : compiled regex
4831
4832 Returns
4833 -------
4834 list of column labels
4835 """
4836 rng = range(regex.groups)
4837 names = {v: k for k, v in regex.groupindex.items()}
4838 if not names:
4839 return rng
4840 result: list[Hashable] = [names.get(1 + i, i) for i in rng]
4841 arr = np.array(result)
4842 if arr.dtype.kind == "i" and lib.is_range_indexer(arr, len(arr)):
4843 return rng
4844 return result
4845
4846
4847def str_extractall(arr, pat, flags: int = 0) -> DataFrame:

Callers 2

extractMethod · 0.85
str_extractallFunction · 0.85

Calls 3

itemsMethod · 0.45
getMethod · 0.45
arrayMethod · 0.45

Tested by

no test coverage detected