📖 Scenario: Imagine you are a data analyst working with sales data from a small store. Before making any decisions or building models, you want to understand the data by looking at it carefully. This helps you find patterns, spot mistakes, and decide what to do next.
🎯 Goal: You will create a small dataset, set a threshold to find high sales, filter the data using that threshold, and then print the filtered results. This shows how exploring data step-by-step helps guide your analysis.
📋 What You'll Learn
Create a dictionary called sales_data with product names as keys and sales numbers as values
Create a variable called high_sales_threshold and set it to 50
Use a dictionary comprehension to create a new dictionary high_sales with only products having sales greater than high_sales_threshold
Print the high_sales dictionary to see the filtered results
💡 Why This Matters
🌍 Real World
Exploratory inspection helps analysts understand data quality and patterns before making decisions or building models.
💼 Career
Data analysts and scientists use exploratory data analysis to guide their work and avoid mistakes.
Progress0 / 4 steps
1
Create the sales data dictionary
Create a dictionary called sales_data with these exact entries: 'Apples': 30, 'Bananas': 55, 'Cherries': 45, 'Dates': 70, 'Elderberries': 20
Data Analysis Python
Hint
Use curly braces {} to create the dictionary with the exact keys and values.
2
Set the high sales threshold
Create a variable called high_sales_threshold and set it to 50
Data Analysis Python
Hint
Just assign the number 50 to the variable high_sales_threshold.
3
Filter products with high sales
Use a dictionary comprehension to create a new dictionary called high_sales that includes only products from sales_data with sales greater than high_sales_threshold
Data Analysis Python
Hint
Use {product: sales for product, sales in sales_data.items() if sales > high_sales_threshold} to filter the dictionary.
4
Print the filtered high sales products
Write a print statement to display the high_sales dictionary
Data Analysis Python
Hint
Use print(high_sales) to show the filtered dictionary.
Practice
(1/5)
1. Why is exploratory inspection important before starting data analysis?
easy
A. It helps understand data quality and guides cleaning steps.
B. It automatically fixes all data errors.
C. It replaces the need for any analysis.
D. It only shows the last rows of data.
Solution
Step 1: Understand the purpose of exploratory inspection
Exploratory inspection helps us see what the data looks like and if there are any problems.
Step 2: Connect inspection to analysis planning
Knowing data quality helps decide how to clean and analyze the data properly.
Final Answer:
It helps understand data quality and guides cleaning steps. -> Option A
Quick Check:
Exploratory inspection guides analysis = B [OK]
Hint: Exploratory inspection reveals data issues early [OK]
Common Mistakes:
Thinking inspection fixes errors automatically
Believing inspection replaces analysis
Confusing head() with tail()
2. Which of the following Python commands is correct to quickly see the first 5 rows of a DataFrame named df?
easy
A. df.show()
B. df.first5()
C. df.top()
D. df.head()
Solution
Step 1: Recall the method to view first rows
The standard method to view the first 5 rows in pandas is head().
Step 2: Check other options for validity
Methods like first5(), top(), and show() do not exist in pandas DataFrame.
Final Answer:
df.head() -> Option D
Quick Check:
df.head() shows first rows [OK]
Hint: Use df.head() to preview first rows [OK]
Common Mistakes:
Using non-existent methods like df.top()
Confusing df.head() with df.tail()
Forgetting parentheses after method name
3. Given the code:
import pandas as pd
data = {'age': [25, 30, 22, 40], 'income': [50000, 60000, 45000, 80000]}
df = pd.DataFrame(data)
print(df.describe())
What will be the output?
medium
A. Summary statistics including count, mean, std, min, 25%, 50%, 75%, max for each column.
B. Only the first 5 rows of the DataFrame.
C. Data types of each column.
D. An error because describe() needs parameters.
Solution
Step 1: Understand what df.describe() does
The describe() method gives summary statistics like count, mean, std, min, quartiles, and max for numeric columns.
Step 2: Check the code context
The DataFrame has numeric columns 'age' and 'income', so describe() will output their statistics.
Final Answer:
Summary statistics including count, mean, std, min, 25%, 50%, 75%, max for each column. -> Option A
Quick Check:
df.describe() = summary stats [OK]
Hint: describe() summarizes numeric columns [OK]
Common Mistakes:
Thinking describe() shows data rows
Expecting data types from describe()
Assuming describe() needs arguments
4. What is wrong with this code snippet for inspecting a DataFrame df?
print(df.info)
medium
A. print() cannot be used with info().
B. Missing parentheses to call the info() method.
C. info() is not a valid method for DataFrame.
D. df.info() returns data, not info.
Solution
Step 1: Identify the method call syntax error
The code uses df.info without parentheses, so it refers to the method object, not calls it.
Step 2: Explain correct usage
To execute and print the info, it should be print(df.info()) with parentheses.
Final Answer:
Missing parentheses to call the info() method. -> Option B
Quick Check:
Method call needs () [OK]
Hint: Always add () to call methods like info() [OK]
Common Mistakes:
Forgetting parentheses on method calls
Thinking info() is not a DataFrame method
Trying to print method object instead of output
5. You have a DataFrame df with columns ['name', 'age', 'salary']. You want to check if there are missing values before analysis. Which code snippet correctly helps you decide the next steps?
hard
A. print(df.columns)
B. print(df.head(10))
C. print(df.isnull().sum())
D. print(df.describe())
Solution
Step 1: Identify method to check missing values
The method isnull() returns True for missing values; summing counts them per column.
Step 2: Understand why other options don't help
head() shows rows but not missing counts, describe() summarizes numeric data, and columns lists column names only.
Final Answer:
print(df.isnull().sum()) -> Option C
Quick Check:
Use isnull().sum() to count missing data [OK]
Hint: Use isnull().sum() to find missing values fast [OK]
Common Mistakes:
Using head() to find missing data
Expecting describe() to show missing counts
Confusing columns attribute with data content
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.