0
0
Data Analysis Pythondata~15 mins

value_counts() for distributions in Data Analysis Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Using value_counts() to Analyze Distributions
📖 Scenario: Imagine you work in a small bookstore. You have a list of books sold in one day. You want to find out how many times each book was sold to understand which books are popular.
🎯 Goal: You will create a list of sold books, then use value_counts() to find the count of each book sold. Finally, you will print the distribution of book sales.
📋 What You'll Learn
Create a list called books_sold with exact book titles.
Create a Pandas Series from the list.
Use value_counts() on the Series to get the count of each book.
Print the result.
💡 Why This Matters
🌍 Real World
Counting how many times each product or item appears in sales data helps businesses understand customer preferences and manage inventory.
💼 Career
Data analysts and data scientists often use <code>value_counts()</code> to quickly summarize categorical data and find patterns.
Progress0 / 4 steps
1
Create the list of books sold
Create a list called books_sold with these exact book titles in this order: 'Python Basics', 'Data Science 101', 'Python Basics', 'Machine Learning', 'Data Science 101', 'Python Basics'.
Data Analysis Python
Need a hint?

Remember to use square brackets [] to create a list and separate items with commas.

2
Create a Pandas Series from the list
Import the pandas library as pd. Then create a variable called books_series by converting the books_sold list into a Pandas Series using pd.Series().
Data Analysis Python
Need a hint?

Use import pandas as pd to import Pandas. Then use pd.Series() to convert the list.

3
Use value_counts() to find the distribution
Create a variable called book_counts by applying value_counts() on the books_series variable.
Data Analysis Python
Need a hint?

Call value_counts() directly on the Series variable.

4
Print the distribution of book sales
Print the book_counts variable to display how many times each book was sold.
Data Analysis Python
Need a hint?

Use print(book_counts) to show the counts.