0
0
Pandasdata~15 mins

Dropping missing values with dropna() in Pandas - Mini Project: Build & Apply

Choose your learning style9 modes available
Dropping missing values with dropna()
📖 Scenario: You have a small dataset of sales records. Some records have missing values. You want to clean the data by removing any rows that have missing values.
🎯 Goal: Build a small pandas DataFrame with sales data, then use dropna() to remove rows with missing values, and finally display the cleaned data.
📋 What You'll Learn
Create a pandas DataFrame called sales_data with exact columns and values
Create a variable called cleaned_data that holds the DataFrame after dropping rows with missing values using dropna()
Print the cleaned_data DataFrame
💡 Why This Matters
🌍 Real World
Cleaning data by removing incomplete records is a common step before analysis or machine learning.
💼 Career
Data scientists and analysts often use <code>dropna()</code> to prepare datasets for accurate insights and models.
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': ['Pen', 'Notebook', 'Pencil', 'Eraser', 'Marker'],
'Price': [1.5, 2.0, None, 0.5, 1.0],
'Quantity': [10, None, 15, 20, 10].
Use None for missing values.
Pandas
Need a hint?

Use pd.DataFrame() with a dictionary. Use None for missing values.

2
Create a variable for cleaned data
Create a variable called cleaned_data that stores the result of calling dropna() on sales_data to remove rows with any missing values.
Pandas
Need a hint?

Use dropna() on sales_data and assign it to cleaned_data.

3
Check the cleaned data
Use print() to display the cleaned_data DataFrame.
Pandas
Need a hint?

Use print(cleaned_data) to see the cleaned DataFrame.

4
View the final cleaned data output
Run the program to see the printed cleaned_data DataFrame without any missing values.
Pandas
Need a hint?

The output should show only rows without any missing values.