Answers for "column value unique pandas"

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

Code answers related to "column value unique pandas"

Python Answers by Framework

Browse Popular Code Answers by Language