Skip to content

Commit afa6c42

Browse files
mlaforetjreback
authored andcommitted
DOC: update the pandas.DataFrame.all docstring (pandas-dev#20216)
1 parent a44bae3 commit afa6c42

File tree

1 file changed

+63
-10
lines changed

1 file changed

+63
-10
lines changed

pandas/core/generic.py

+63-10
Original file line numberDiff line numberDiff line change
@@ -7584,11 +7584,10 @@ def _add_numeric_operations(cls):
75847584
cls.any = _make_logical_function(
75857585
cls, 'any', name, name2, axis_descr,
75867586
'Return whether any element is True over requested axis',
7587-
nanops.nanany)
7587+
nanops.nanany, '', '')
75887588
cls.all = _make_logical_function(
7589-
cls, 'all', name, name2, axis_descr,
7590-
'Return whether all elements are True over requested axis',
7591-
nanops.nanall)
7589+
cls, 'all', name, name2, axis_descr, _all_doc,
7590+
nanops.nanall, _all_examples, _all_see_also)
75927591

75937592
@Substitution(outname='mad',
75947593
desc="Return the mean absolute deviation of the values "
@@ -7845,25 +7844,78 @@ def _doc_parms(cls):
78457844
%(outname)s : %(name1)s or %(name2)s (if level specified)\n"""
78467845

78477846
_bool_doc = """
7848-
78497847
%(desc)s
78507848
78517849
Parameters
78527850
----------
78537851
axis : %(axis_descr)s
78547852
skipna : boolean, default True
78557853
Exclude NA/null values. If an entire row/column is NA, the result
7856-
will be NA
7854+
will be NA.
78577855
level : int or level name, default None
78587856
If the axis is a MultiIndex (hierarchical), count along a
7859-
particular level, collapsing into a %(name1)s
7857+
particular level, collapsing into a %(name1)s.
78607858
bool_only : boolean, default None
78617859
Include only boolean columns. If None, will attempt to use everything,
78627860
then use only boolean data. Not implemented for Series.
7861+
**kwargs : any, default None
7862+
Additional keywords have no affect but might be accepted for
7863+
compatibility with numpy.
78637864
78647865
Returns
78657866
-------
7866-
%(outname)s : %(name1)s or %(name2)s (if level specified)\n"""
7867+
%(outname)s : %(name1)s or %(name2)s (if level specified)
7868+
7869+
%(examples)s
7870+
%(see_also)s"""
7871+
7872+
_all_doc = """\
7873+
Return whether all elements are True over series or dataframe axis.
7874+
7875+
Returns True if all elements within a series or along a dataframe
7876+
axis are non-zero, not-empty or not-False."""
7877+
7878+
_all_examples = """\
7879+
Examples
7880+
--------
7881+
Series
7882+
7883+
>>> pd.Series([True, True]).all()
7884+
True
7885+
>>> pd.Series([True, False]).all()
7886+
False
7887+
7888+
Dataframes
7889+
7890+
Create a dataframe from a dictionary.
7891+
7892+
>>> df = pd.DataFrame({'col1': [True, True], 'col2': [True, False]})
7893+
>>> df
7894+
col1 col2
7895+
0 True True
7896+
1 True False
7897+
7898+
Default behaviour checks if column-wise values all return True.
7899+
7900+
>>> df.all()
7901+
col1 True
7902+
col2 False
7903+
dtype: bool
7904+
7905+
Adding axis=1 argument will check if row-wise values all return True.
7906+
7907+
>>> df.all(axis=1)
7908+
0 True
7909+
1 False
7910+
dtype: bool
7911+
"""
7912+
7913+
_all_see_also = """\
7914+
See also
7915+
--------
7916+
pandas.Series.all : Return True if all elements are True
7917+
pandas.DataFrame.any : Return True if one (or more) elements are True
7918+
"""
78677919

78687920
_cnum_doc = """
78697921
@@ -8046,9 +8098,10 @@ def cum_func(self, axis=None, skipna=True, *args, **kwargs):
80468098
return set_function_name(cum_func, name, cls)
80478099

80488100

8049-
def _make_logical_function(cls, name, name1, name2, axis_descr, desc, f):
8101+
def _make_logical_function(cls, name, name1, name2, axis_descr, desc, f,
8102+
examples, see_also):
80508103
@Substitution(outname=name, desc=desc, name1=name1, name2=name2,
8051-
axis_descr=axis_descr)
8104+
axis_descr=axis_descr, examples=examples, see_also=see_also)
80528105
@Appender(_bool_doc)
80538106
def logical_func(self, axis=None, bool_only=None, skipna=None, level=None,
80548107
**kwargs):

0 commit comments

Comments
 (0)