-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
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
Changes from 3 commits
2bb43b8
70695c2
0adc9d3
6eefa7b
65ba74a
231fdcc
23c2c3d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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. | ||
|
||
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]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PEP8: space after commas There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ################################################################################ Return whether all elements are True. Parameters*args Returnsall : bool or array_like (if axis is specified)
################################################################################ Errors found: |
||
>>> 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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
@@ -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 | ||
|
There was a problem hiding this comment.
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