Skip to content

DOC: Docstring pandas index all any #20168

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 7 commits into from
Mar 13, 2018
Merged
Changes from 3 commits
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
57 changes: 52 additions & 5 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ def to_frame(self, index=True):
>>> idx = pd.Index(['Ant', 'Bear', 'Cow'], name='animal')
>>> idx.to_frame()
animal
animal
animal
Ant Ant
Bear Bear
Cow Cow
Expand Down Expand Up @@ -4246,20 +4246,67 @@ def _add_logical_methods(cls):
""" add in logical methods """

_doc = """

%(desc)s

Parameters
----------
All arguments to numpy.%(outname)s are accepted.
*args
These parameters will be passed to numpy.%(outname)s.
**kwargs
These parameters will be passed to numpy.%(outname)s.

Returns
-------
%(outname)s : bool or array_like (if axis is specified)
A single element array_like may be converted to bool."""

_index_shared_docs['index_all'] = """

See Also
--------
pandas.Index.any : Return whether any element is True.

Copy link
Contributor

Choose a reason for hiding this comment

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

pandas.Series.any as well

Notes
-----
Not a Number (NaN), positive infinity and negative infinity
evaluate to True because these are not equal to zero.

Examples
--------
>>> index = pd.Index([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.

PEP8: space after commas

Copy link
Contributor Author

Choose a reason for hiding this comment

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

################################################################################
######################### Docstring (pandas.Index.all) #########################
################################################################################

Return whether all elements are True.

Parameters

*args
These parameters will be passed to numpy.all.
**kwargs
These parameters will be passed to numpy.all.

Returns

all : bool or array_like (if axis is specified)
A single element array_like may be converted to bool.

    See Also
    --------
    pandas.Index.any : Return whether any element is True.

    Notes
    -----
    Not a Number (NaN), positive infinity and negative infinity
    evaluate to True because these are not equal to zero.

    Examples
    --------
    >>> index = pd.Index([1, 2, 3])
    >>> index.all()
    True

    >>> index = pd.Index([0, 1, 2])
    >>> index.all()
    False

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

Errors found:
No extended summary found
Errors in parameters section
Parameters {'kwargs', 'args'} not documented
Unknown parameters {'**kwargs', '*args'}
Parameter "*args" has no type
Parameter "**kwargs" has no type

>>> index.all()
True

>>> index = pd.Index([0,1,2])
>>> index.all()
False
"""

_index_shared_docs['index_any'] = """

See Also
--------
pandas.Index.all : Return whether all elements are True.
Copy link
Contributor

Choose a reason for hiding this comment

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

pandas.Series.all


Notes
-----
Not a Number (NaN), positive infinity and negative infinity
evaluate to True because these are not equal to zero.

Examples
--------
>>> index = pd.Index([0,1,2])
>>> index.any()
True

>>> index = pd.Index([0,0,0])
>>> index.any()
False
"""

def _make_logical_function(name, desc, f):
@Substitution(outname=name, desc=desc)
@Appender(_index_shared_docs['index_' + name])
@Appender(_doc)
def logical_func(self, *args, **kwargs):
result = f(self.values)
Expand All @@ -4274,10 +4321,10 @@ def logical_func(self, *args, **kwargs):
return logical_func

cls.all = _make_logical_function('all', 'Return whether all elements '
'are True',
'are True.',
np.all)
cls.any = _make_logical_function('any',
'Return whether any element is True',
'Return whether any element is True.',
np.any)

@classmethod
Expand Down