Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Find and count unique values of a single column 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 count unique values of column fruits
print(df.fruits.value_counts())
Source by itsmycode.com #
 
PREVIOUS NEXT
Tagged: #Find #count #unique #values #single #column #Pandas #DataFrame
ADD COMMENT
Topic
Name
1+5 =