Skip to content

DOC: Add example to extract docstring, and re-explain change to match. #5826

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 1 commit into from
Jan 3, 2014

Conversation

danielballan
Copy link
Contributor

@jreback, I added examples per your request in #5099. Also, I rewrote the explanation of how str.match is changing, which I left confusing and wordy before.

Compare to the string method match, which returns re.match objects.
Examples
--------
# A pattern with one group will return a Series. Non-matches will be NaN.
Copy link
Member

Choose a reason for hiding this comment

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

No need for the #. Just the explanation line, optionally ending with a :, then a blank line, and then the code example. In that case, the code example will be rendered nicely as code. Like this:

A pattern with more than one group will return a DataFrame:

>>> Series(['a1', 'b2', 'c3']).str.extract('([ab])(\d)')

Named groups will become column names in the result:
...

@jorisvandenbossche
Copy link
Member

Nice examples in the docstring! I added some comments related to numpy's docstring standard.

And a suggestion, while you are at it, maybe you could also add a 'See also' section to refer to match and contain?

@jreback
Copy link
Contributor

jreback commented Jan 2, 2014

looks good....

lmk when you are ready for merging...

@danielballan
Copy link
Contributor Author

Thanks for the help, @jorisvandenbossche . I read up on the numpy documentation standard. Ready to merge.

jreback added a commit that referenced this pull request Jan 3, 2014
DOC: Add example to extract docstring, and re-explain change to match.
@jreback jreback merged commit 1dda3fb into pandas-dev:master Jan 3, 2014
@jreback
Copy link
Contributor

jreback commented Jan 3, 2014

@danielballan thanks...the py2.6 failure was bogus...

@danielballan danielballan deleted the extract-docstring branch January 3, 2014 15:26
boolean Series
if as_indexer=True
Series of tuples
if as_indexer=False, default but deprecated

Returns
Copy link
Member

Choose a reason for hiding this comment

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

You forgot to remove the old 'return'

@jorisvandenbossche
Copy link
Member

@danielballan I added some more comments. Do you want to handle it a new PR (otherwise I can also do it)?

@danielballan
Copy link
Contributor Author

Ah, I thought you wanted output only for the first example, for brevity. I should have asked for clarification. See #5838 .

@jorisvandenbossche
Copy link
Member

@danielballan yeah, maybe that wasn't very clear. But I think the examples are much more valuable to users if you can see in a glimpse the possible outputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants