Skip to content

DOC: fix return type of str.extract #22562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 3, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions pandas/core/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind briefly explaining what these flags are about. Nothing long, but something a bit more descriptive than what we've got now just linking to the re documentation. Something like "Flags that modify regular expression matching for things like case, spaces, etc."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

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
Expand All @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add double backticks around expand=False? (i.e. ``expand=True``)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

a Series (if subject is a Series) or Index (if subject is an
Index).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to this, it can also return a Series or Index, do you mind adding it to the type? So, instead of DataFrame it's DataFrame, Series or Index

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

I addressed the above three issues in one commit. Hopefully it works. Next time, I suppose I should separate them.


See Also
--------
Expand Down