Skip to content

Commit 4577064

Browse files
committed
DOC: expand gotchas/basics on boolean reductions
1 parent 5e806bf commit 4577064

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

doc/source/basics.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ These operations produce a pandas object the same type as the left-hand-side inp
214214
that if of dtype ``bool``. These ``boolean`` objects can be used in indexing operations,
215215
see :ref:`here<indexing.boolean>`
216216

217+
Boolean Reductions
218+
~~~~~~~~~~~~~~~~~~
219+
220+
.. _basics.reductions:
221+
217222
Furthermore, you can apply the reduction functions: ``any()`` and ``all()`` to provide a
218223
way to summarize these results.
219224

@@ -222,6 +227,12 @@ way to summarize these results.
222227
(df>0).all()
223228
(df>0).any()
224229
230+
You can reduce to a final boolean value.
231+
232+
.. ipython:: python
233+
234+
(df>0).any().any()
235+
225236
Finally you can test if a pandas object is empty, via the ``empty`` property.
226237

227238
.. ipython:: python

doc/source/gotchas.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ or, you might want to compare if the pandas object is ``None``
5050
print("I was not None")
5151
>>> I was not None
5252
53+
.. code-block:: python
54+
55+
>>> if pd.Series([False, True, False]).any():
56+
print("I am any")
57+
>>> I am any
58+
59+
See :ref:`boolean reductions<basics.reductions>` for more examples.
60+
5361
Bitwise boolean
5462
~~~~~~~~~~~~~~~
5563

0 commit comments

Comments
 (0)