Locked lesson.
About this lesson
In this video, we discuss how to find unique values within a column and how to find value counts as well.
Exercise files
Download this lesson’s related exercise files.
Operations: Unique Values and Value Counts.docx57.3 KB Operations: Unique Values and Value Counts - Solution.docx
55.5 KB
Quick reference
Operations: Unique Values and Value Counts
In this video we'll learn how to return unique values of columns and counts of unique values.
When to use
Use these two functions to return unique values of a column, and to count the number of unique values in a column.
Instructions
To return a Numpy Array of Unique Values in a column:
my_df["Wed"].unique()
To return a DataFrame of Unique Values in a column:
pd.DataFrame(my_df["Wed"].unique())
To count how many Unique Values are in a column:
my_df["Wed"].nunique()
Hints & tips
- Unique Values: my_df["Wed"].unique()
- my_df["Wed"].nunique()
Lesson notes are only available for subscribers.