How to Get Frequency Counts of a Column in Pandas Dataframe: Pandas Tutorial

Often while working with pandas dataframe you might have a column with categorical variables, string/characters, and you want to find the frequency counts of each unique elements present in the column. Pandas’ value_counts() easily let you get the frequency counts.

Let us get started with an example from a real world data set.

Load gapminder data set

# import pandas as pd
import pandas as pd
# software carpentry url for gapminder data
gapminder_csv_url =''
# load the data with pd.read_csv
gapminder = pd.read_csv(gapminder_csv_url)

Frequency Counts of the column “continent”

Let us say we want to find the frequency counts of column ‘continent’ in the data frame. We can use pandas’ function value_counts on the column of interest. It will return NumPy array with unique items and the frequency of it.

Africa      624
Asia        396
Europe      360
Americas    300
Oceania      24

If you just want the unique values from a pandas dataframe column, it is pretty simple. Check here