From 1f427353554e6403f87c01f81b6e414427faa5f0 Mon Sep 17 00:00:00 2001 From: Abhinav Sagar <40603139+abhinavsagar@users.noreply.github.com> Date: Wed, 29 May 2019 10:43:35 +0530 Subject: DOC: Add note to ``nonzero`` docstring. (#13551) * Added NOTE in numpy\core\fromnumeric.py --- numpy/core/fromnumeric.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'numpy/core/fromnumeric.py') diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index 202802e2c..af2a5298d 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -1795,6 +1795,11 @@ def nonzero(a): Equivalent ndarray method. count_nonzero : Counts the number of non-zero elements in the input array. + + Notes + ----- + To obtain the non-zero values, it is recommended to use ``x[x.astype(bool)]`` + which will correctly handle 0-d arrays. Examples -------- -- cgit v1.2.1