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
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

Find unique values in all columns in Pandas DataFrame

# 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 all columns
for col in df:
  print(df			
							
		.unique())
Posted by: Guest on January-15-2022
2

count unique values pandas

df['hID'].nunique()
5
Posted by: Guest on May-28-2020
1

pandas count unique values in column

df.nunique()
Posted by: Guest on March-12-2020
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"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language