Skip to content

DOC: Improved the docstring of pandas.Series.filter #20148

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 4 commits into from
Jul 7, 2018

Conversation

ottiP
Copy link
Contributor

@ottiP ottiP commented Mar 10, 2018

Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):

  • PR title is "DOC: update the docstring"
  • The validation script passes: scripts/validate_docstrings.py <your-function-or-method>
  • The PEP8 style check passes: git diff upstream/master -u -- "*.py" | flake8 --diff
  • The html version looks good: python doc/make.py --single <your-function-or-method>
  • It has been proofread on language by another sprint participant

Please include the output of the validation script below between the "```" ticks:

################################################################################
####################### Docstring (pandas.Series.filter) #######################
################################################################################

Subset rows or columns of dataframe according to labels in
the specified index.

Note that this routine does not filter a dataframe on its
contents. The filter is applied to the labels of the index.

Parameters
----------
items : list-like
    List of info axis to restrict to (must not all be present).
like : string
    Keep info axis where "arg in col == True".
regex : string (regular expression)
    Keep info axis with re.search(regex, col) == True.
axis : int or string axis name
    The axis to filter on.  By default this is the info axis,
    'index' for Series, 'columns' for DataFrame.

Returns
-------
same type as input object

Examples
--------
>>> df = pd.DataFrame(np.array(([1,2,3],[4,5,6])),
...                   index=['mouse', 'rabbit'],
...                   columns=['one', 'two', 'three'])

>>> # select columns by name
>>> df.filter(items=['one', 'three'])
         one  three
mouse     1      3
rabbit    4      6

>>> # select columns by regular expression
>>> df.filter(regex='e$', axis=1)
         one  three
mouse     1      3
rabbit    4      6

>>> # select rows containing 'bbi'
>>> df.filter(like='bbi', axis=0)
         one  two  three
rabbit    4    5      6

See Also
--------
pandas.DataFrame.loc : Purely label-location based indexer for selection by label.

Notes
-----
The ``items``, ``like``, and ``regex`` parameters are
enforced to be mutually exclusive.

``axis`` defaults to the info axis that is used when indexing
with ``[]``.

################################################################################
################################## Validation ##################################
################################################################################

Docstring for "pandas.Series.filter" correct. :)

If the validation script still gives errors, but you think there is a good reason
to deviate in this case (and there are certainly such cases), please state this
explicitly.

Checklist for other PRs (remove this part if you are doing a PR for the pandas documentation sprint):

@pep8speaks
Copy link

pep8speaks commented Mar 10, 2018

Hello @ottiP! Thanks for updating the PR.

Cheers ! There are no PEP8 issues in this Pull Request. 🍻

Comment last updated on July 07, 2018 at 14:47 Hours UTC

@ottiP ottiP force-pushed the doc_generic_filter branch from e9fa518 to aa0af81 Compare March 10, 2018 14:23
@@ -3525,46 +3525,45 @@ def filter(self, items=None, like=None, regex=None, axis=None):
Parameters
----------
items : list-like
List of info axis to restrict to (must not all be present)
List of info axis to restrict to (must not all be present).
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I don't think info axis is well known. How about "List of labels from axis to restrict to."

Copy link
Contributor

Choose a reason for hiding this comment

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

And maybe replace all other "info axis" with `axis`

one two three
mouse 1 2 3
rabbit 4 5 6
>>> df = pd.DataFrame(np.array(([1,2,3],[4,5,6])),
Copy link
Contributor

Choose a reason for hiding this comment

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

PEP8: spaces after comma

rabbit 4 5 6

See Also
--------
pandas.DataFrame.loc
pandas.DataFrame.loc : Purely label-location based indexer for selection by label.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe too long. Just "label-based indexer."

@@ -3794,6 +3793,19 @@ def sample(self, n=None, frac=None, replace=False, weights=None,
40 0.823173 -0.078816 1.009536 1.015108
15 1.421154 -0.055301 -1.922594 -0.019696
6 -0.148339 0.832938 1.787600 -1.383767

You can use `random state` for reproducibility:
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this from a different PR?

@ottiP ottiP force-pushed the doc_generic_filter branch 2 times, most recently from 5d0ea2e to 28121ba Compare March 10, 2018 14:38
@codecov
Copy link

codecov bot commented Jul 7, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@dcbf8b5). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #20148   +/-   ##
=========================================
  Coverage          ?   91.95%           
=========================================
  Files             ?      160           
  Lines             ?    49817           
  Branches          ?        0           
=========================================
  Hits              ?    45810           
  Misses            ?     4007           
  Partials          ?        0
Flag Coverage Δ
#multiple 90.33% <ø> (?)
#single 42.08% <ø> (?)
Impacted Files Coverage Δ
pandas/core/generic.py 96.45% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dcbf8b5...1708c15. Read the comment docs.

@jreback jreback added this to the 0.24.0 milestone Jul 7, 2018
@jreback
Copy link
Contributor

jreback commented Jul 7, 2018

@datapythonista if you want to merge this on green.

@jreback jreback merged commit f37a6a2 into pandas-dev:master Jul 7, 2018
@jreback
Copy link
Contributor

jreback commented Jul 7, 2018

thanks @ottiP !

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

Successfully merging this pull request may close these issues.

5 participants