0
0
Pandasdata~15 mins

Counting missing values in Pandas - Mini Project: Build & Apply

Choose your learning style9 modes available
Counting missing values
📖 Scenario: You work as a data analyst. You have a small table of sales data. Some values are missing because the data was not recorded properly.You want to find out how many missing values are in the data to understand its quality.
🎯 Goal: Create a pandas DataFrame with sales data including some missing values. Then count how many missing values are in each column.
📋 What You'll Learn
Use pandas to create a DataFrame
Include missing values using None or numpy.nan
Count missing values per column using pandas methods
Print the count of missing values
💡 Why This Matters
🌍 Real World
Data scientists often check for missing data to decide how to clean or fill it before analysis.
💼 Career
Counting missing values is a basic but essential skill for data cleaning in data analyst and data scientist roles.
Progress0 / 4 steps
1
Create the sales data DataFrame
Import pandas as pd and create a DataFrame called sales_data with these exact columns and values:
'Product': ['Apple', 'Banana', 'Orange', 'Grapes'],
'Price': [1.2, None, 0.8, 2.5],
'Quantity': [10, 15, None, 8].
Pandas
Need a hint?

Use pd.DataFrame with a dictionary where keys are column names and values are lists of column data.

2
Create a variable to hold missing values count
Create a variable called missing_counts and set it to None. This will hold the count of missing values later.
Pandas
Need a hint?

Just write missing_counts = None to prepare the variable.

3
Count missing values in each column
Set the variable missing_counts to the result of calling sales_data.isnull().sum(). This counts missing values per column.
Pandas
Need a hint?

Use sales_data.isnull() to find missing values, then .sum() to count them per column.

4
Print the missing values count
Print the variable missing_counts to show the count of missing values in each column.
Pandas
Need a hint?

Use print(missing_counts) to display the counts.