Python | Pandas Index.nunique() Last Updated : 18 Dec, 2018 Summarize Comments Improve Suggest changes Share 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 Index.nunique() function return number of unique elements in the object. It returns a scalar value which is the count of all the unique values in the Index. By default the NaN values are not included in the count. If dropna parameter is set to be False then it includes NaN value in the count. Syntax: Index.nunique(dropna=True) Parameters : dropna : Don’t include NaN in the count. Returns : nunique : int Example #1: Use Index.nunique()() function to find the count of unique values in the Index. Do not include NaN values in the count. Python3 # importing pandas as pd import pandas as pd # Creating the index idx = pd.Index(['Beagle', 'Pug', 'Labrador', 'Pug', 'Mastiff', None, 'Beagle']) # Print the Index idx Output : Let's find the count of unique values in the Index. Python3 # to find the count of unique values. idx.nunique(dropna = True) Output : As we can see in the output, the function has returned 4 indicating that there are only 4 unique values in the Index. Example #2: Use Index.nunique() function find out all the unique values in the Index. Also include the missing values i.e. NaN values in the count. Python3 # importing pandas as pd import pandas as pd # Creating the index idx = pd.Index(['Beagle', 'Pug', 'Labrador', 'Pug', 'Mastiff', None, 'Beagle']) # Print the Index idx Output : Let's find the count of unique values in the Index. Python3 # to find the count of unique values. idx.nunique(dropna = False) Output : As we can see in the output, the function has returned 5 indicating that there are only 5 unique values in the Index. We have also included the missing values in the count. Comment More infoAdvertise with us Next Article Pandas Index.notnull()-Python S Shubham__Ranjan Follow Improve Article Tags : Technical Scripter Python Python-pandas Python pandas-indexing Practice Tags : python Similar Reads Python | Pandas Index.ndim Pandas Index is an immutable ndarray implementing an ordered, sliceable set. It is the basic object which stores the axis labels for all pandas objects. Pandas Index.ndim attribute return the number of dimensions of the underlying data in the given Index object. By definition it is 1. Syntax: Index. 2 min read Python | Pandas Index.notna() 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 Index.notna() function Detect existing (non-missing) values. Return a boolean sa 2 min read Pandas Index.notnull()-Python Index.notnull() function in pandas detect non-missing (non-NaN/None) values within a pandas Index. It returns a boolean array where True indicates the element is valid (not null) and False indicates it is missing. Example: Pythonimport pandas as pd import numpy as np idx = pd.Index([1, 2, np.nan, 4] 2 min read Python | Pandas Index.min() 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 Index.min() function returns the minimum value of the Index. The function works 2 min read Python | Pandas Index.nbytes Pandas Index is an immutable ndarray implementing an ordered, sliceable set. It is the basic object which stores the axis labels for all pandas objects. Pandas Index.nbytes attribute return the number of bytes required to store the underlying data of the given Index object. Syntax: Index.nbytes Para 2 min read Python | Pandas Index.insert() 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 Index.insert() function make new Index inserting new item at location. This fun 2 min read Like