Sample questions
Question 1Easy
In pandas, missing numeric values are usually represented as:
- 0
- NaN
- -1
- "missing"
Answer: B. NaN
Explanation
NaN (Not a Number) marks missing floating-point values.
Step-by-step solution
- pandas uses NaN (Not a Number) for missing numeric values.
- None in a numeric column is converted to NaN.
Why the other options are wrong
- A. 0 is a real value, not missing.
- C. -1 is a placeholder some systems use, not pandas' default.
- D. A text marker is not pandas' missing value.
Tip: Use isna(), not == np.nan.
Question 2Easy
Which pandas function reads a CSV file into a DataFrame?
pd.load()pd.open_csv()pd.csv()pd.read_csv()
Answer: D. pd.read_csv()
Explanation
read_csv parses a CSV file into a DataFrame.
Step-by-step solution
- pd.read_csv('file.csv') reads a CSV file.
- It returns a DataFrame with one column per CSV field.
Why the other options are wrong
- A. pd.load is not a pandas function.
- B. pd.open_csv is not a pandas function.
- C. pd.csv is not a pandas function.
Tip: read_* to load; to_* to save.
Question 3Easy
Which pandas method removes duplicate rows?
dropna()drop_duplicates()unique_rows()fillna()
Answer: B. drop_duplicates()
Explanation
drop_duplicates keeps the first occurrence by default.
Step-by-step solution
- drop_duplicates() removes repeated rows.
- It keeps the first occurrence by default.
Why the other options are wrong
- A. dropna removes missing values.
- C. unique_rows is not a pandas method.
- D. fillna fills missing values.
Tip: duplicated() to find; drop_duplicates() to remove.
Question 4Easy
Which DataFrame method shows the first five rows?
show()first()top()head()
Answer: D. head()
Explanation
head(n) returns the first n rows, defaulting to 5.
Step-by-step solution
- df.head() shows the first 5 rows by default.
- head(n) shows n rows.
Why the other options are wrong
- A. show() is not a pandas DataFrame method.
- B. first() is for time-based offsets, not the first 5 rows.
- C. top() is not a DataFrame method.
Tip: head() and tail() default to 5 rows.
Question 5Medium
Min-max scaling maps the value 30 in a column ranging from 10 to 60 to:
- 0.3
- 0.5
- 0.4
- 0.6
Answer: C. 0.4
Explanation
(30 - 10) / (60 - 10) = 20 / 50 = 0.4.
Step-by-step solution
- Min-max: (x - min) / (max - min).
- (30 - 10) / (60 - 10) = 20 / 50.
- = 0.4.
Why the other options are wrong
- A. 0.3 does not use (x - min) / (max - min).
- B. 0.5 is 30/60.
- D. 0.6 has no basis.
Tip: (x - min) / (max - min).
Question 6Medium
For a categorical column like "city" with a few missing values, a common simple imputation is:
- Random numbers
- The standard deviation
- The mode, or "Unknown"
- The mean
Answer: C. The mode, or "Unknown"
Explanation
Means do not exist for categories; use the most frequent value or a separate "Unknown" label.
Step-by-step solution
- City is categorical, so mean and SD do not apply.
- Use the most frequent city (mode).
- Or create an explicit 'Unknown' category.
Why the other options are wrong
- A. Random numbers are meaningless for city names.
- B. SD applies only to numbers.
- D. You cannot average city names.
Tip: Categorical gaps: mode or 'Unknown'.
Question 7Medium
Standardisation (z-score scaling) transforms a feature so that it has:
- Only integer values
- Mean 0 and standard deviation 1
- Values between 0 and 1
- Median 1 and range 0
Answer: B. Mean 0 and standard deviation 1
Explanation
z = (x - mean) / SD. Min-max scaling, by contrast, maps values into [0, 1].
Step-by-step solution
- z = (x - mean) / SD for each value.
- The transformed feature has mean 0 and SD 1.
Why the other options are wrong
- A. z-scores are usually decimals.
- C. 0 to 1 is min-max scaling.
- D. That is not a property of z-scaling.
Tip: Standardise: mean 0, SD 1; Min-max: 0 to 1.
Question 8Medium
Which check verifies that every order's customer_id exists in the customers table?
- Referential integrity check
- Spell check
- Range check on dates
- Uniqueness check on order_id
Answer: A. Referential integrity check
Explanation
Orphan foreign keys reveal broken links between tables.
Step-by-step solution
- orders.customer_id should match a customers row.
- Checking this is a referential integrity (foreign key) check.
- In SQL, a LEFT JOIN where customers.id IS NULL finds orphans.
Why the other options are wrong
- B. Spell checks are for text.
- C. Range checks verify values fall in a range.
- D. Uniqueness checks look for duplicate keys.
Tip: Orphan check: LEFT JOIN ... WHERE parent key IS NULL.
Question 9Hard
Which approach handles outliers appropriately?
- Always replace them with zero
- Ignore them in every case
- Always delete them
- Investigate, then fix only real errors
Answer: D. Investigate, then fix only real errors
Explanation
Some outliers are data errors; others (e.g. a genuine large order) are important.
Step-by-step solution
- First check why the value is extreme.
- If it is an error, correct or remove it.
- If it is genuine, keep it (perhaps using robust methods).
Why the other options are wrong
- A. Zero is usually as wrong as the outlier.
- B. Ignoring real errors leads to wrong results.
- C. Genuine extremes carry real information.
Tip: Investigate before you delete.
Question 10Hard
A dataset's "revenue" column mixes values in rupees and in lakhs. What is this issue called and how is it fixed?
- Mixed units; convert to one unit
- Missing values; drop the column
- Skewness; take the log
- Duplicates; remove rows
Answer: A. Mixed units; convert to one unit
Explanation
Unit mismatches must be standardised before aggregation.
Step-by-step solution
- Some values are in rupees, others in lakhs (1 lakh = 100,000 rupees).
- Mixing units makes sums and comparisons wrong.
- Convert everything to one unit.
Why the other options are wrong
- B. The values exist; they just use different units.
- C. Log transforms skew, not units.
- D. These are not duplicate rows.
Tip: One column, one unit.
Practise all 25 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →