A. DataFrame with all rows including those with None values
B. DataFrame with rows containing None values replaced by 0
C. DataFrame with rows containing None values removed
D. Error because dropna() is not a valid method
Solution
Step 1: Understand what dropna() does in pandas
dropna() removes rows that have any missing (None/NaN) values.
Step 2: Apply dropna() to the DataFrame
Rows with None in 'age' or 'score' are removed, leaving only rows with complete data.
Final Answer:
DataFrame with rows containing None values removed -> Option C
Quick Check:
dropna() removes rows with missing data [OK]
Hint: dropna() removes rows with missing values [OK]
Common Mistakes:
Thinking dropna() replaces missing values
Expecting an error from dropna()
Assuming dropna() keeps all rows
4. Identify the error in this data exploration code and choose the correct fix:
import pandas as pd
data = {'height': [170, 165, 180], 'weight': [65, 70, 75]}
df = pd.DataFrame(data)
print(df.mean(axis=1))
medium
A. No error, code runs correctly
B. Use df.mean() without axis parameter
C. Replace df.mean(axis=1) with df.sum(axis=1)
D. Change axis=1 to axis=0 to get mean of columns
Solution
Step 1: Understand what df.mean(axis=1) does
axis=1 calculates the mean across columns for each row, which is valid here.
Step 2: Check if code runs without error
The code runs correctly and prints the mean height and weight per row.
Final Answer:
No error, code runs correctly -> Option A
Quick Check:
df.mean(axis=1) calculates row means [OK]
Hint: axis=1 means row-wise operation [OK]
Common Mistakes:
Thinking axis=1 causes error
Confusing axis=0 and axis=1
Replacing mean with sum unnecessarily
5. You have a dataset with sales data including missing values. Which sequence of steps correctly follows the data analysis workflow to find average sales per region?
Options: A) Collect data -> Visualize data -> Clean data -> Explore data -> Conclude B) Collect data -> Clean data -> Explore data -> Visualize data -> Conclude C) Clean data -> Collect data -> Explore data -> Visualize data -> Conclude D) Collect data -> Explore data -> Clean data -> Visualize data -> Conclude
hard
A. Collect data -> Visualize data -> Clean data -> Explore data -> Conclude
B. Collect data -> Explore data -> Clean data -> Visualize data -> Conclude
C. Clean data -> Collect data -> Explore data -> Visualize data -> Conclude
D. Collect data -> Clean data -> Explore data -> Visualize data -> Conclude
Solution
Step 1: Recall the correct order of data analysis workflow
The standard order is: collect data, clean data, explore data, visualize data, then conclude.
Step 2: Match the options to this order
Collect data -> Clean data -> Explore data -> Visualize data -> Conclude matches the correct sequence exactly.
Final Answer:
Collect data -> Clean data -> Explore data -> Visualize data -> Conclude -> Option D