@@ -4550,20 +4550,86 @@ def _add_logical_methods(cls):
4550
4550
""" add in logical methods """
4551
4551
4552
4552
_doc = """
4553
-
4554
4553
%(desc)s
4555
4554
4556
4555
Parameters
4557
4556
----------
4558
- All arguments to numpy.%(outname)s are accepted.
4557
+ *args
4558
+ These parameters will be passed to numpy.%(outname)s.
4559
+ **kwargs
4560
+ These parameters will be passed to numpy.%(outname)s.
4559
4561
4560
4562
Returns
4561
4563
-------
4562
4564
%(outname)s : bool or array_like (if axis is specified)
4563
4565
A single element array_like may be converted to bool."""
4564
4566
4567
+ _index_shared_docs ['index_all' ] = """
4568
+
4569
+ See Also
4570
+ --------
4571
+ pandas.Index.any : Return whether any element in an Index is True.
4572
+ pandas.Series.any : Return whether any element in a Series is True.
4573
+ pandas.Series.all : Return whether all elements in a Series are True.
4574
+
4575
+ Notes
4576
+ -----
4577
+ Not a Number (NaN), positive infinity and negative infinity
4578
+ evaluate to True because these are not equal to zero.
4579
+
4580
+ Examples
4581
+ --------
4582
+ **all**
4583
+
4584
+ True, because nonzero integers are considered True.
4585
+
4586
+ >>> pd.Index([1, 2, 3]).all()
4587
+ True
4588
+
4589
+ False, because ``0`` is considered False.
4590
+
4591
+ >>> pd.Index([0, 1, 2]).all()
4592
+ False
4593
+
4594
+ **any**
4595
+
4596
+ True, because ``1`` is considered True.
4597
+
4598
+ >>> pd.Index([0, 0, 1]).any()
4599
+ True
4600
+
4601
+ False, because ``0`` is considered False.
4602
+
4603
+ >>> pd.Index([0, 0, 0]).any()
4604
+ False
4605
+ """
4606
+
4607
+ _index_shared_docs ['index_any' ] = """
4608
+
4609
+ See Also
4610
+ --------
4611
+ pandas.Index.all : Return whether all elements are True.
4612
+ pandas.Series.all : Return whether all elements are True.
4613
+
4614
+ Notes
4615
+ -----
4616
+ Not a Number (NaN), positive infinity and negative infinity
4617
+ evaluate to True because these are not equal to zero.
4618
+
4619
+ Examples
4620
+ --------
4621
+ >>> index = pd.Index([0, 1, 2])
4622
+ >>> index.any()
4623
+ True
4624
+
4625
+ >>> index = pd.Index([0, 0, 0])
4626
+ >>> index.any()
4627
+ False
4628
+ """
4629
+
4565
4630
def _make_logical_function (name , desc , f ):
4566
4631
@Substitution (outname = name , desc = desc )
4632
+ @Appender (_index_shared_docs ['index_' + name ])
4567
4633
@Appender (_doc )
4568
4634
def logical_func (self , * args , ** kwargs ):
4569
4635
result = f (self .values )
@@ -4578,10 +4644,10 @@ def logical_func(self, *args, **kwargs):
4578
4644
return logical_func
4579
4645
4580
4646
cls .all = _make_logical_function ('all' , 'Return whether all elements '
4581
- 'are True' ,
4647
+ 'are True. ' ,
4582
4648
np .all )
4583
4649
cls .any = _make_logical_function ('any' ,
4584
- 'Return whether any element is True' ,
4650
+ 'Return whether any element is True. ' ,
4585
4651
np .any )
4586
4652
4587
4653
@classmethod
0 commit comments