Python | Pandas Series.nonzero() to get Index of all non zero values in a series Last Updated : 30 Sep, 2019 Comments Improve Suggest changes Like Article Like Report Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas Series.nonzero() is an argument less method. Just like it name says, rather returning non zero values from a series, it returns index of all non zero values. The returned series of indices can be passed to iloc method and return all non zero values. Syntax: Series.nonzero() Return type: Array of indices Example: In this example, a Series is created from a Python List using Pandas Series() method. The series also contains some zero values. After that nonzero() method is called on series and the result is stored in result variable. The result series is then passed to iloc() method to return all non zero values at that indices. Python3 1== # importing pandas module import pandas as pd # importing numpy module import numpy as np # creating list list =[1, 0, 12, 1, 0, 4, 22, 0, 3, 9] # creating series series = pd.Series(list) # calling .nonzero() method result = series.nonzero() # display print(result) # retrieving values using iloc method values = series.iloc[result] # display values Output: (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 output, the index position of every non zero elements was returned and the values at that position were returned using iloc method. Comment More infoAdvertise with us Next Article Python | Pandas Series.nonzero() to get Index of all non zero values in a series K Kartikaybhutani Follow Improve Article Tags : Technical Scripter Python Python-pandas Python pandas-series Python pandas-series-methods +1 More Practice Tags : python Similar Reads Python | Pandas Series.cumsum() to find cumulative sum of a Series Pandas Series.cumsum() is used to find Cumulative sum of a series. In cumulative sum, the length of returned series is same as input and every element is equal to sum of all previous elements. Syntax: Series.cumsum(axis=None, skipna=True) Parameters: axis: 0 or 'index' for row wise operation and 1 o 2 min read Pandas - Get the elements of series that are not present in other series Sometimes we have two or more series and we have to find all those elements that are present in one series but not in other. We can do this easily, using the Bitwise NOT operator along with the pandas.isin() function. Example 1: Taking two Integer Series Python3 # Importing pandas library import pan 2 min read Python | Pandas Series.cummin() to find cumulative minimum of a series Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas Series.cummin() is used to find Cumulative minimum of a series. In cumulative m 2 min read Python | Pandas series.cummax() to find Cumulative maximum of a series Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas Series.cummax() is used to find Cumulative maximum of a series. In cumulative m 3 min read Python | Pandas series.cumprod() to find Cumulative product of a Series Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas Series.cumprod() is used to find Cumulative product of a series. In cumulative 3 min read Like