Data Science with Python Certification Data Science with Python Exploratory Data Analysis 3 — Questions and Answers
Question 1: What does a Pearson correlation coefficient of -0.95 between two variables indicate?
- A weak negative linear relationship
- A strong negative linear relationship (Correct answer)
- No relationship between the variables
- A strong positive linear relationship
Correct answer: A strong negative linear relationship
A value close to -1 indicates a strong negative linear relationship where one variable increases as the other decreases.
Question 2: Which pandas function is used to reshape a DataFrame from wide format to long format?
- pd.pivot()
- pd.melt() (Correct answer)
- pd.crosstab()
- pd.stack()
Correct answer: pd.melt()
pd.melt() unpivots a DataFrame from wide to long format by converting column headers into row values.
Question 3: In EDA, what does a KDE (Kernel Density Estimate) plot show?
- A discrete frequency count of bins
- A smoothed continuous estimate of the probability density function (Correct answer)
- The cumulative sum of a variable
- The rank order of observations
Correct answer: A smoothed continuous estimate of the probability density function
A KDE plot estimates the probability density of a continuous variable by smoothing the data using a kernel function.
Question 4: What is the effect of calling df.fillna(df.mean()) on a DataFrame with missing numeric values?
- Replaces NaN with zero in all columns
- Replaces NaN in each column with that column's mean value (Correct answer)
- Drops all rows containing NaN
- Replaces NaN with the global mean of all columns combined
Correct answer: Replaces NaN in each column with that column's mean value
df.mean() computes a per-column mean Series, and fillna() replaces each column's NaN values with its own mean.
Question 5: Which of the following best describes a violin plot in EDA?
- A plot showing only the median and quartiles
- A combination of a box plot and a KDE that shows distribution shape (Correct answer)
- A scatter plot with regression lines
- A bar chart of category frequencies
Correct answer: A combination of a box plot and a KDE that shows distribution shape
A violin plot mirrors the KDE on both sides of a central axis while embedding a mini box plot to show quartiles and median.
Question 6: What does df['col'].value_counts(normalize=True) return?
- The absolute count of each unique value
- The relative frequency (proportion) of each unique value (Correct answer)
- The cumulative frequency of each unique value
- The z-score of each unique value's count
Correct answer: The relative frequency (proportion) of each unique value
normalize=True divides each count by the total number of observations, returning proportions that sum to 1.
Question 7: When analyzing a dataset for outliers using the IQR method, which values are typically flagged?
- Values beyond 1 standard deviation from the mean
- Values below Q1 - 1.5*IQR or above Q3 + 1.5*IQR (Correct answer)
- Values in the top and bottom 5% of the distribution
- Values more than 2 standard deviations from the median
Correct answer: Values below Q1 - 1.5*IQR or above Q3 + 1.5*IQR
The standard IQR fence rule flags points that fall below Q1 - 1.5×IQR or above Q3 + 1.5×IQR as potential outliers.
What does a Pearson correlation coefficient of -0.95 between two variables indicate?