Data Science with Python Certification Data Science with Python Exploratory Data Analysis 5 — Questions and Answers
Question 1: Which pandas method efficiently identifies columns with more than 50% missing values?
- df.isnull().mean() > 0.5 (Correct answer)
- df.describe()['count'] < len(df) / 2
- df.notna().sum() < 0.5
- df.info() filtered by dtype
Correct answer: df.isnull().mean() > 0.5
df.isnull().mean() computes the fraction of missing values per column; comparing to 0.5 returns a boolean mask of columns exceeding 50% nulls.
Question 2: In EDA, what is the main advantage of using a pair plot (sns.pairplot()) over individual scatter plots?
- It only works with categorical variables
- It shows all pairwise relationships and univariate distributions in a single grid (Correct answer)
- It calculates correlation coefficients automatically
- It removes outliers before plotting
Correct answer: It shows all pairwise relationships and univariate distributions in a single grid
sns.pairplot() creates a grid of scatter plots for every pair of numeric variables and histograms/KDEs on the diagonal, giving a comprehensive overview.
Question 3: What does df.astype({'age': 'int32', 'score': 'float32'}) accomplish?
- Renames the columns age and score
- Casts the specified columns to new data types to reduce memory usage (Correct answer)
- Drops rows where age or score are non-numeric
- Rounds age and score to 32 decimal places
Correct answer: Casts the specified columns to new data types to reduce memory usage
astype() with a dict changes each named column to the specified dtype, which can significantly reduce memory footprint.
Question 4: Which statistic is most resistant to the influence of outliers when describing the center of a distribution?
- Mean
- Median (Correct answer)
- Mode
- Variance
Correct answer: Median
The median is the middle value and is not pulled by extreme outliers, making it a robust measure of central tendency.
Question 5: What is the purpose of applying Z-score standardization during EDA before visualization?
- To convert categorical variables to numeric
- To place variables on a common scale for fair comparison (Correct answer)
- To remove duplicate rows from the dataset
- To encode ordinal rankings as integers
Correct answer: To place variables on a common scale for fair comparison
Z-score standardization (subtracting the mean and dividing by std) rescales features to have mean 0 and std 1, enabling meaningful comparison across different scales.
Question 6: When df.groupby('region').agg({'revenue': 'sum', 'units': 'mean'}) is called, what is the index of the result?
- A RangeIndex starting at 0
- The unique values of the 'region' column (Correct answer)
- A MultiIndex of (region, column)
- The original DataFrame's index
Correct answer: The unique values of the 'region' column
After groupby().agg(), the grouping column ('region') becomes the index of the resulting DataFrame.
Question 7: Which of the following is a correct interpretation of a right-skewed (positively skewed) distribution?
- The mean is less than the median
- The tail extends to the right and the mean exceeds the median (Correct answer)
- The distribution is symmetric around the mean
- Most values cluster at the high end of the range
Correct answer: The tail extends to the right and the mean exceeds the median
In a right-skewed distribution, a long tail on the right pulls the mean above the median, indicating more mass on the lower end of the scale.
Which pandas method efficiently identifies columns with more than 50% missing values?