Answers for "how to retuen the unique values of the columnsof a dataframe"

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

dataframe python unique values rows

# get the unique values (rows)
df.drop_duplicates()
Posted by: Guest on June-03-2020

Code answers related to "how to retuen the unique values of the columnsof a dataframe"

Python Answers by Framework

Browse Popular Code Answers by Language