From bfeacbb16b6bc7000b3c22b88badf44fb65fdcf2 Mon Sep 17 00:00:00 2001 From: zhujun98 Date: Sat, 1 Sep 2018 11:43:14 +0200 Subject: [PATCH 1/2] DOC: fix return type of str.extract --- pandas/core/strings.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/pandas/core/strings.py b/pandas/core/strings.py index e455c751057d1..202eac2163a73 100644 --- a/pandas/core/strings.py +++ b/pandas/core/strings.py @@ -854,8 +854,8 @@ def str_extract(arr, pat, flags=0, expand=True): pat : string Regular expression pattern with capturing groups. flags : int, default 0 (no flags) - ``re`` module flags, e.g. ``re.IGNORECASE``. - See :mod:`re` + One of the ``re`` module flags, e.g. ``re.IGNORECASE``. + 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 @@ -865,13 +865,15 @@ def str_extract(arr, pat, flags=0, expand=True): Returns ------- - 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). + DataFrame + 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 -------- From acd9147497371deec87759e0fe22d62104d0fb55 Mon Sep 17 00:00:00 2001 From: zhujun98 Date: Sun, 2 Sep 2018 09:16:05 +0200 Subject: [PATCH 2/2] DOC: a few minor improvements for str.extract --- pandas/core/strings.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pandas/core/strings.py b/pandas/core/strings.py index 202eac2163a73..e078f6ce3d5c7 100644 --- a/pandas/core/strings.py +++ b/pandas/core/strings.py @@ -854,8 +854,9 @@ def str_extract(arr, pat, flags=0, expand=True): pat : string Regular expression pattern with capturing groups. flags : int, default 0 (no flags) - One of the ``re`` module flags, e.g. ``re.IGNORECASE``. - See :mod:`re`. + 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 @@ -865,15 +866,15 @@ def str_extract(arr, pat, flags=0, expand=True): Returns ------- - DataFrame + 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). + ``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 --------