Skip to content

DOC: Improved the docstring of Series.any() #20078

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

Closed
wants to merge 5 commits into from

Conversation

FrankDupree
Copy link

@FrankDupree FrankDupree commented Mar 9, 2018

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

  • PR title is "DOC: Improved the docstring of Series.any()"
  • The validation script passes: scripts/validate_docstrings.py Series.any()
  • The PEP8 style check passes: git diff upstream/master -u -- "*.py" | flake8 --diff
  • The html version looks good: python doc/make.py --single Series.any()
  • 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.any)  ########################
################################################################################

Return whether any element is True over requested axis.

Returns True if one (or more) elements are non-zero,
not-empty or not-False.

Parameters
----------
axis : {index (0)}
skipna : boolean, default True
    Exclude NA/null values. If an entire row/column is NA, the result
    will be NA.
level : int or level name, default None
    If the axis is a MultiIndex (hierarchical), count along a
    particular level, collapsing into a scalar.
bool_only : boolean, default None
    Include only boolean columns. If None, will attempt to use everything,
    then use only boolean data. Not implemented for Series.
**kwargs : Additional keywords have no effect but might be accepted for
    compatibility with numpy.

Returns
-------
any : scalar or Series (if level specified)

Examples
--------
>>> s1 = pd.Series([1, 2, 3])
>>> s1.any()
True

>>> import numpy as np
>>> s2 = pd.Series([np.NaN, np.NaN, np.NaN])
>>> s2.any()
False

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

Errors found:
        Errors in parameters section
                Parameters {'kwargs'} not documented
                Unknown parameters {'**kwargs'}
                Parameter "axis" has no description
                Parameter "**kwargs" description should start with capital letter
        See Also section not found

Participants of the documentation sprint were told to go ahead with the description of the "**kwargs" parameter.

Parameter "axis" has no description looks like a bug to me. Noticed some other methods show the same validation error. e.g "pandas.Series.mean" throws the same validation error.

@TomAugspurger
Copy link
Contributor

Does this close a specific issue?


Examples
--------
>>> s1 = pd.Series([1,2,3])
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add spaces after the commas here so this is pep8 compliant?

Copy link
Author

Choose a reason for hiding this comment

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

Okay, will do.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

>>> s2.any()
False

>>> s3 = pd.Series([1,2,3,"Hobbit"])
Copy link
Contributor

Choose a reason for hiding this comment

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

This last one is a bug: #12863 It should return True / False.

I think just remove it for now.

Copy link
Author

Choose a reason for hiding this comment

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

yeah, I sensed it 👍

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@codecov
Copy link

codecov bot commented Mar 9, 2018

Codecov Report

Merging #20078 into master will increase coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #20078      +/-   ##
==========================================
+ Coverage    91.7%   91.72%   +0.02%     
==========================================
  Files         150      150              
  Lines       49122    49149      +27     
==========================================
+ Hits        45045    45083      +38     
+ Misses       4077     4066      -11
Flag Coverage Δ
#multiple 90.11% <ø> (+0.02%) ⬆️
#single 41.85% <ø> (-0.02%) ⬇️
Impacted Files Coverage Δ
pandas/core/generic.py 95.84% <ø> (ø) ⬆️
pandas/core/groupby.py 92.14% <0%> (-0.01%) ⬇️
pandas/io/html.py 86.6% <0%> (+0.62%) ⬆️
pandas/plotting/_converter.py 66.81% <0%> (+1.73%) ⬆️

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 731d971...680f48c. Read the comment docs.

@datapythonista
Copy link
Member

@FrankDupree can you please read carefully the doc on how to submit a PR [1], and make sure you do all the steps correctly? You surely missed the point about the title of the PR, and also copying the output of the validate_docstrings.py in the description. Without those, it's difficult to understand what you sent and review it.

Btw, in the description of the PR, the [ ] are checkboxes. You should make sure you completed every listed point, and mark them with an [X], so we know you did.

Thank you!

  1. https://python-sprints.github.io/pandas/guide/pandas_pr.html

@FrankDupree FrankDupree changed the title Pandas series fix DOC: Improved the docstring of Series.any() Mar 10, 2018
@toobaz
Copy link
Member

toobaz commented Mar 10, 2018

Are Parameter "axis" has no description and See Also section not found solved? If yes, could you update the description?

%(desc)s

Returns True if one (or more) elements are non-zero,
not-empty or not-False.

Parameters
----------
axis : %(axis_descr)s
Copy link
Member

Choose a reason for hiding this comment

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

Missing description

Copy link
Member

Choose a reason for hiding this comment

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

(never mind)

@toobaz
Copy link
Member

toobaz commented Mar 10, 2018

Please update the description with the validation script output

bool_only : boolean, default None
Include only boolean columns. If None, will attempt to use everything,
then use only boolean data. Not implemented for Series.
**kwargs : Additional keywords have no effect but might be accepted for
Copy link
Contributor

Choose a reason for hiding this comment

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

@datapythonista is this the language generally recommending here?

Copy link
Member

Choose a reason for hiding this comment

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

I didn't see this earlier. I think the description is similar to the ones used in kwargs with similar behavior. But it should go in the next line, as in the other parameters, and in this line simply leave **kwargs

@jreback jreback added the Docs label Mar 10, 2018
@jreback jreback added this to the 0.23.0 milestone Mar 10, 2018
@TomAugspurger
Copy link
Contributor

@FrankDupree Some things have changed in master. Can you check if there's anything else to be done?

@FrankDupree
Copy link
Author

@TomAugspurger I will.

@jorisvandenbossche
Copy link
Member

So it seems we had a conflicting PR #20217 that implemented DataFrame.any, and since Series and DataFrame share code, this might have been duplicate work .. Sorry about that!

I am going to close this PR, but please check if there is anything in your PR that is not in http://pandas-docs.github.io/pandas-docs-travis/generated/pandas.Series.any.html#pandas.Series.any.
For example, I think it would be good to add an example of what an empty Series returns (Series([]).any()). Feel free to open a PR for that.

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.

6 participants