Answers for "pandas how to find unique values in a column"

2

get list of unique values in pandas column

a = df['column name'].unique() #returns a list of unique values
Posted by: Guest on March-29-2021
1

get count of unique values in column pandas

df = df.groupby('domain')['ID'].nunique()

print (df)
domain
'facebook.com'    1
'google.com'      1
'twitter.com'     2
'vk.com'          3
Name: ID, dtype: int64
Posted by: Guest on May-28-2020
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
0

how to get unique value of all columns in pandas

print(df.apply(lambda col: col.unique()))
Posted by: Guest on August-05-2021
0

python unique values from pandas.series of sets

df['category'].explode().value_counts()
Posted by: Guest on December-06-2021

Code answers related to "pandas how to find unique values in a column"

Python Answers by Framework

Browse Popular Code Answers by Language