Answers for "how to find if column has unique values pandas"

3

How to Find Unique Values in a Column in Pandas

# import pandas library
import pandas as pd

# create pandas DataFrame
df = pd.DataFrame({'fruits': ['orange', 'mango', 'apple', 'grapes', 'orange', 'mango'],
                   'price': ['40', '80', '30', '40', '30', '80'],
                   'quantity': ['200', '300', '300', '400', '200', '800']
                   })

# get the unique value of column fruits
print(df.fruits.unique())
Posted by: Guest on January-15-2022
1

pandas count unique values in column

df.nunique()
Posted by: Guest on March-12-2020

Code answers related to "how to find if column has unique values pandas"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language