Pandas Series.nonzero()
— it is a method with no arguments. As the name suggests, by returning non-zero values ‚Äã‚Äãfrom a series, it returns the index of all non-zero values. The returned series of indexes can be passed to the method iloc ()
to return all nonzero values ​​at those indices.
|
Exit:
(array ([0, 2, 3, 5, 6 , 8, 9]),) 0 1 2 12 3 1 5 4 6 22 8 3 9 9 dtype: int64
As shown in the output, the index position of each nonzero element was returned, and the values ​​in this positions were returned by the iloc
method.