# pandas 3.1.0 (BSD-3-Clause), harvested by tools/harvest_corpus.py
=== input

        Extract capture groups in the regex `pat` as columns in a DataFrame.

        For each subject string in the Series, extract groups from the
        first match of regular expression `pat`.

        Parameters
        ----------
        pat : str
            Regular expression pattern with capturing groups.
        flags : int, default 0 (no flags)
            Flags from the ``re`` module, e.g. ``re.IGNORECASE``, that
            modify regular expression matching for things like case,
            spaces, etc. For more details, see :mod:`re`.
        expand : bool, default True
            If True, return DataFrame with one column per capture group.
            If False, return a Series/Index if there is one capture group
            or DataFrame if there are multiple capture groups.

        Returns
        -------
        DataFrame or Series or Index
            A DataFrame with one row for each subject string, and one
            column for each group. Any capture group names in regular
            expression pat will be used for column names; otherwise
            capture group numbers will be used. The dtype of each result
            column is always object, even when no match is found. If
            ``expand=False`` and pat has only one capture group, then
            return a Series (if subject is a Series) or Index (if subject
            is an Index).

        See Also
        --------
        extractall : Returns all matches (not just the first match).

        Examples
        --------
        A pattern with two groups will return a DataFrame with two columns.
        Non-matches will be NaN.

        >>> s = pd.Series(["a1", "b2", "c3"])
        >>> s.str.extract(r"([ab])(\d)")
            0    1
        0    a    1
        1    b    2
        2  NaN  NaN

        A pattern may contain optional groups.

        >>> s.str.extract(r"([ab])?(\d)")
            0  1
        0    a  1
        1    b  2
        2  NaN  3

        Named groups will become column names in the result.

        >>> s.str.extract(r"(?P<letter>[ab])(?P<digit>\d)")
        letter digit
        0      a     1
        1      b     2
        2    NaN   NaN

        A pattern with one group will return a DataFrame with one column
        if expand=True.

        >>> s.str.extract(r"[ab](\d)", expand=True)
             0
        0    1
        1    2
        2  NaN

        A pattern with one group will return a Series if expand=False.

        >>> s.str.extract(r"[ab](\d)", expand=False)
        0      1
        1      2
        2    NaN
        dtype: str
        
=== parse numpydoc
short_description: 'Extract capture groups in the regex `pat` as columns in a DataFrame.'
long_description: |
  For each subject string in the Series, extract groups from the
  first match of regular expression `pat`.
blank_after_short_description: True
blank_after_long_description: True
style: numpydoc
- DocstringParam
  description: 'Regular expression pattern with capturing groups.'
  kind: param
  key: 'param'
  arg_name: 'pat'
  type_name: 'str'
  is_optional: False
- DocstringParam
  description: |
    Flags from the ``re`` module, e.g. ``re.IGNORECASE``, that
    modify regular expression matching for things like case,
    spaces, etc. For more details, see :mod:`re`.
  kind: param
  key: 'param'
  arg_name: 'flags'
  type_name: 'int'
  is_optional: True
  default: '0 (no flags)'
  raw_type_name: 'int, default 0 (no flags)'
- DocstringParam
  description: |
    If True, return DataFrame with one column per capture group.
    If False, return a Series/Index if there is one capture group
    or DataFrame if there are multiple capture groups.
  kind: param
  key: 'param'
  arg_name: 'expand'
  type_name: 'bool'
  is_optional: True
  default: 'True'
  raw_type_name: 'bool, default True'
- DocstringReturns
  description: |
    A DataFrame with one row for each subject string, and one
    column for each group. Any capture group names in regular
    expression pat will be used for column names; otherwise
    capture group numbers will be used. The dtype of each result
    column is always object, even when no match is found. If
    ``expand=False`` and pat has only one capture group, then
    return a Series (if subject is a Series) or Index (if subject
    is an Index).
  kind: returns
  key: 'returns'
  type_name: 'DataFrame or Series or Index'
  is_generator: False
- DocstringMeta
  description: 'extractall : Returns all matches (not just the first match).'
  kind: text
  key: 'see_also'
  title: 'See Also'
- DocstringExample
  description: |
    A pattern with two groups will return a DataFrame with two columns.
    Non-matches will be NaN.
  kind: examples
  key: 'examples'
  snippet: '>>> s = pd.Series(["a1", "b2", "c3"])'
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: |
    >>> s.str.extract(r"([ab])(\d)")
        0    1
    0    a    1
    1    b    2
    2  NaN  NaN
- DocstringExample
  description: 'A pattern may contain optional groups.'
  kind: examples
  key: 'examples'
  snippet: |
    >>> s.str.extract(r"([ab])?(\d)")
        0  1
    0    a  1
    1    b  2
    2  NaN  3
- DocstringExample
  description: 'Named groups will become column names in the result.'
  kind: examples
  key: 'examples'
  snippet: |
    >>> s.str.extract(r"(?P<letter>[ab])(?P<digit>\d)")
    letter digit
    0      a     1
    1      b     2
    2    NaN   NaN
- DocstringExample
  description: |
    A pattern with one group will return a DataFrame with one column
    if expand=True.
  kind: examples
  key: 'examples'
  snippet: |
    >>> s.str.extract(r"[ab](\d)", expand=True)
         0
    0    1
    1    2
    2  NaN
- DocstringExample
  description: 'A pattern with one group will return a Series if expand=False.'
  kind: examples
  key: 'examples'
  snippet: |
    >>> s.str.extract(r"[ab](\d)", expand=False)
    0      1
    1      2
    2    NaN
    dtype: str
=== detect
numpydoc
=== compose numpydoc
Extract capture groups in the regex `pat` as columns in a DataFrame.

For each subject string in the Series, extract groups from the
first match of regular expression `pat`.

Parameters
----------
pat : str
    Regular expression pattern with capturing groups.
flags : int, default 0 (no flags)
    Flags from the ``re`` module, e.g. ``re.IGNORECASE``, that
    modify regular expression matching for things like case,
    spaces, etc. For more details, see :mod:`re`.
expand : bool, default True
    If True, return DataFrame with one column per capture group.
    If False, return a Series/Index if there is one capture group
    or DataFrame if there are multiple capture groups.

Returns
-------
DataFrame or Series or Index
    A DataFrame with one row for each subject string, and one
    column for each group. Any capture group names in regular
    expression pat will be used for column names; otherwise
    capture group numbers will be used. The dtype of each result
    column is always object, even when no match is found. If
    ``expand=False`` and pat has only one capture group, then
    return a Series (if subject is a Series) or Index (if subject
    is an Index).

See Also
--------
extractall : Returns all matches (not just the first match).

Examples
--------
A pattern with two groups will return a DataFrame with two columns.
Non-matches will be NaN.

>>> s = pd.Series(["a1", "b2", "c3"])
>>> s.str.extract(r"([ab])(\d)")
    0    1
0    a    1
1    b    2
2  NaN  NaN

A pattern may contain optional groups.

>>> s.str.extract(r"([ab])?(\d)")
    0  1
0    a  1
1    b  2
2  NaN  3

Named groups will become column names in the result.

>>> s.str.extract(r"(?P<letter>[ab])(?P<digit>\d)")
letter digit
0      a     1
1      b     2
2    NaN   NaN

A pattern with one group will return a DataFrame with one column
if expand=True.

>>> s.str.extract(r"[ab](\d)", expand=True)
     0
0    1
1    2
2  NaN

A pattern with one group will return a Series if expand=False.

>>> s.str.extract(r"[ab](\d)", expand=False)
0      1
1      2
2    NaN
dtype: str
