Counting Unique Values with nunique() for Cardinality
📖 Scenario: You work in a small bookstore. You have a list of books sold each day. You want to find out how many different book titles were sold.
🎯 Goal: Build a small program that counts the number of unique book titles sold using the nunique() method.
📋 What You'll Learn
Create a pandas DataFrame with a column named
book_title containing the exact book titles sold.Create a variable called
unique_books_count to store the number of unique book titles using nunique().Print the value of
unique_books_count.💡 Why This Matters
🌍 Real World
Counting unique items sold helps businesses understand product variety and customer preferences.
💼 Career
Data analysts often count unique values to summarize data and find important insights.
Progress0 / 4 steps