Counting Unique Values with pandas nunique()
📖 Scenario: You work at a small bookstore. You have a list of books sold each day. You want to find out how many unique book titles were sold each day.
🎯 Goal: Build a small program using pandas to count unique book titles sold per day using the nunique() function.
📋 What You'll Learn
Create a pandas DataFrame with sales data including 'day' and 'book_title' columns.
Create a variable to hold the day to analyze.
Use
nunique() to count unique book titles sold on that day.Print the count of unique book titles sold on the chosen day.
💡 Why This Matters
🌍 Real World
Counting unique items sold or recorded is common in sales, inventory, and customer data analysis.
💼 Career
Data analysts and scientists often use <code>nunique()</code> to quickly find how many distinct values exist in a dataset column.
Progress0 / 4 steps