unique(): Pandas DataFrame

Pandas

We will get unique values and its frequency as series.

Parameters

values: 1-D array input.

Examples with Parameters

The name of classes ( unique )
import pandas as pd 
my_dict={'NAME':['Ravi','Raju','Alex','Ron','King','Jack'],
         'ID':[1,2,3,4,5,6],
         'GAME':['CRICKET','TENNIS','CRICKET','HOCKEY','CRICKET','TENNIS'],
         'CLASS1':['Four','Three','Three','Four','Five','Three']}
my_data = pd.DataFrame(data=my_dict)
print(my_data['CLASS1'].unique())
Output
['Four' 'Three' 'Five']
We will get unique games played by students.
print(my_data['GAME'].unique())
Output
['CRICKET' 'TENNIS' 'HOCKEY']
What are the number of unique data ( use nunique() ).
print(my_data['CLASS1'].nunique())
Output
3
value_counts()

Pandas DataFrame cut() segment and sort data values into bins

Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here





    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2021 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer