Get named groups from compiled regex. Unnamed groups are numbered. Parameters ---------- regex : compiled regex Returns ------- list of column labels
(regex: re.Pattern)
| 4820 | |
| 4821 | |
| 4822 | def _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 | |
| 4847 | def str_extractall(arr, pat, flags: int = 0) -> DataFrame: |
no test coverage detected