Finding the number of unique values
You would like to practice some of the categorical data manipulation and analysis skills that you've just seen. To help identify which data could be reformatted to extract value, you are going to find out which non-numeric columns in the planes
dataset have a large number of unique values.
pandas
has been imported for you as pd
, and the dataset has been stored as planes
.
This exercise is part of the course
Exploratory Data Analysis in Python
Exercise instructions
- Filter
planes
for columns that are of"object"
data type. - Loop through the columns in the dataset.
- Add the column iterator to the print statement, then call the function to return the number of unique values in the column.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Filter the DataFrame for object columns
non_numeric = planes._____("____")
# Loop through columns
for ____ in non_numeric.____:
# Print the number of unique values
print(f"Number of unique values in {____} column: ", non_numeric[____].____())