@@ -9894,11 +9894,11 @@ def _add_numeric_operations(cls):
9894
9894
axis_descr , name , name2 = _doc_parms (cls )
9895
9895
9896
9896
cls .any = _make_logical_function (
9897
- cls , 'any' , name , name2 , axis_descr ,
9898
- _any_desc , nanops . nanany , _any_examples , _any_see_also )
9897
+ cls , 'any' , name , name2 , axis_descr , _any_desc , nanops . nanany ,
9898
+ _any_examples , _any_see_also , empty_value = False )
9899
9899
cls .all = _make_logical_function (
9900
- cls , 'all' , name , name2 , axis_descr , _all_doc ,
9901
- nanops . nanall , _all_examples , _all_see_also )
9900
+ cls , 'all' , name , name2 , axis_descr , _all_desc , nanops . nanall ,
9901
+ _all_examples , _all_see_also , empty_value = True )
9902
9902
9903
9903
@Substitution (outname = 'mad' ,
9904
9904
desc = "Return the mean absolute deviation of the values "
@@ -10219,12 +10219,14 @@ def _doc_parms(cls):
10219
10219
original index.
10220
10220
* None : reduce all axes, return a scalar.
10221
10221
10222
- bool_only : boolean , default None
10222
+ bool_only : bool , default None
10223
10223
Include only boolean columns. If None, will attempt to use everything,
10224
10224
then use only boolean data. Not implemented for Series.
10225
- skipna : boolean, default True
10226
- Exclude NA/null values. If an entire row/column is NA, the result
10227
- will be NA.
10225
+ skipna : bool, default True
10226
+ Exclude NA/null values. If the entire row/column is NA and skipna is
10227
+ True, then the result will be %(empty_value)s, as for an empty row/column.
10228
+ If skipna is False, then NA are treated as True, because these are not
10229
+ equal to zero.
10228
10230
level : int or level name, default None
10229
10231
If the axis is a MultiIndex (hierarchical), count along a
10230
10232
particular level, collapsing into a %(name1)s.
@@ -10234,28 +10236,37 @@ def _doc_parms(cls):
10234
10236
10235
10237
Returns
10236
10238
-------
10237
- %(outname)s : %(name1)s or %(name2)s (if level specified)
10239
+ %(name1)s or %(name2)s
10240
+ If level is specified, then, %(name2)s is returned; otherwise, %(name1)s
10241
+ is returned.
10238
10242
10239
10243
%(see_also)s
10240
10244
%(examples)s"""
10241
10245
10242
- _all_doc = """\
10246
+ _all_desc = """\
10243
10247
Return whether all elements are True, potentially over an axis.
10244
10248
10245
- Returns True if all elements within a series or along a Dataframe
10246
- axis are non-zero, not-empty or not-False."""
10249
+ Returns True unless there at least one element within a series or
10250
+ along a Dataframe axis that is False or equivalent (e.g. zero or
10251
+ empty)."""
10247
10252
10248
10253
_all_examples = """\
10249
10254
Examples
10250
10255
--------
10251
- Series
10256
+ ** Series**
10252
10257
10253
10258
>>> pd.Series([True, True]).all()
10254
10259
True
10255
10260
>>> pd.Series([True, False]).all()
10256
10261
False
10262
+ >>> pd.Series([]).all()
10263
+ True
10264
+ >>> pd.Series([np.nan]).all()
10265
+ True
10266
+ >>> pd.Series([np.nan]).all(skipna=False)
10267
+ True
10257
10268
10258
- DataFrames
10269
+ ** DataFrames**
10259
10270
10260
10271
Create a dataframe from a dictionary.
10261
10272
@@ -10597,10 +10608,11 @@ def _doc_parms(cls):
10597
10608
"""
10598
10609
10599
10610
_any_desc = """\
10600
- Return whether any element is True over requested axis.
10611
+ Return whether any element is True, potentially over an axis.
10601
10612
10602
- Unlike :meth:`DataFrame.all`, this performs an *or* operation. If any of the
10603
- values along the specified axis is True, this will return True."""
10613
+ Returns False unless there at least one element within a series or
10614
+ along a Dataframe axis that is True or equivalent (e.g. non-zero or
10615
+ non-empty)."""
10604
10616
10605
10617
_any_examples = """\
10606
10618
Examples
@@ -10610,8 +10622,16 @@ def _doc_parms(cls):
10610
10622
For Series input, the output is a scalar indicating whether any element
10611
10623
is True.
10612
10624
10625
+ >>> pd.Series([False, False]).any()
10626
+ False
10613
10627
>>> pd.Series([True, False]).any()
10614
10628
True
10629
+ >>> pd.Series([]).any()
10630
+ False
10631
+ >>> pd.Series([np.nan]).any()
10632
+ False
10633
+ >>> pd.Series([np.nan]).any(skipna=False)
10634
+ True
10615
10635
10616
10636
**DataFrame**
10617
10637
@@ -10897,9 +10917,10 @@ def cum_func(self, axis=None, skipna=True, *args, **kwargs):
10897
10917
10898
10918
10899
10919
def _make_logical_function (cls , name , name1 , name2 , axis_descr , desc , f ,
10900
- examples , see_also ):
10920
+ examples , see_also , empty_value ):
10901
10921
@Substitution (outname = name , desc = desc , name1 = name1 , name2 = name2 ,
10902
- axis_descr = axis_descr , examples = examples , see_also = see_also )
10922
+ axis_descr = axis_descr , examples = examples , see_also = see_also ,
10923
+ empty_value = empty_value )
10903
10924
@Appender (_bool_doc )
10904
10925
def logical_func (self , axis = 0 , bool_only = None , skipna = True , level = None ,
10905
10926
** kwargs ):
0 commit comments