MS-DS Master of Data science FREE MS-DS Master of Data science Data Wrangling and Preprocessing Questions and Answers 2 — Questions and Answers
Question 1: Which pandas method is most appropriate for combining two DataFrames that share a common key column?
- merge() (Correct answer)
- append()
- concat()
- stack()
Correct answer: merge()
The merge() function performs database-style joins on DataFrames using one or more common key columns.
Question 2: What is the primary purpose of one-hot encoding in data preprocessing?
- Converting categorical variables into binary columns (Correct answer)
- Normalizing numerical features to a 0-1 range
- Removing duplicate rows from a dataset
- Imputing missing values with the mode
Correct answer: Converting categorical variables into binary columns
One-hot encoding transforms each category of a categorical variable into a separate binary column indicating presence or absence.
Question 3: When dealing with a heavily right-skewed numerical feature, which transformation is commonly applied to reduce skewness?
- Log transformation (Correct answer)
- Min-max scaling
- Mean imputation
- Label encoding
Correct answer: Log transformation
Log transformation compresses the range of large values and spreads out smaller values, effectively reducing right skewness.
Question 4: What does the pandas melt() function accomplish in data wrangling?
- Converts wide-format data to long-format (Correct answer)
- Removes rows with missing values
- Merges multiple DataFrames vertically
- Applies aggregate functions to grouped data
Correct answer: Converts wide-format data to long-format
The melt() function unpivots a wide-format DataFrame into a longer format by turning column headers into row values.
Question 5: Which strategy for handling missing data is most likely to introduce bias when data is not missing completely at random?
- Listwise deletion (Correct answer)
- Multiple imputation
- K-nearest neighbors imputation
- Regression imputation
Correct answer: Listwise deletion
Listwise deletion removes entire rows with any missing values, which can systematically exclude certain subgroups and introduce bias when missingness depends on observed or unobserved data.
Question 6: In feature engineering, what is the purpose of creating interaction terms between two variables?
- To capture the combined effect of two features that may not be represented by either alone (Correct answer)
- To reduce the dimensionality of the dataset
- To normalize the distribution of both features
- To remove multicollinearity between the features
Correct answer: To capture the combined effect of two features that may not be represented by either alone
Interaction terms model the joint effect of two features, capturing relationships where the impact of one variable depends on the level of another.
Which pandas method is most appropriate for combining two DataFrames that share a common key column?