Loading

Quipoin Menu

Learn • Practice • Grow

python-for-ai / Data Filtering
mcq
Direction: Choose the correct option

Q1.

How do you filter rows where a column `age` is greater than 30?
A. df.filter(age > 30)
B. Both A and B
C. df[df['age'] > 30]
D. df[df.age > 30]
Direction: Choose the correct option

Q2.

What does `df[df['name'] == 'Alice']` return?
A. Rows where name is not Alice
B. All rows
C. Error
D. Rows where name is Alice
Direction: Choose the correct option

Q3.

How do you combine multiple conditions with logical AND?
A. df[df['age'] > 30 & df['score'] < 10]
B. df[(df['age'] > 30) & (df['score'] < 10)]
C. df[df['age'] > 30 and df['score'] < 10]
D. Both A and B
Direction: Choose the correct option

Q4.

What is the output of `df[df['age'].between(18, 30)]`?
A. Rows with age >18 and <30
B. None
C. Rows with age between 18 and 30 exclusive
D. Rows with age between 18 and 30 inclusive
Direction: Choose the correct option

Q5.

How do you filter rows where column value is in a list?
A. df[df['city'] == ['NY', 'LA']]
B. df[df['city'].isin(['NY', 'LA'])]
C. df.filter(city=['NY','LA'])
D. df[df['city'] in ['NY', 'LA']]
Direction: Choose the correct option

Q6.

What does `df.query('age > 30')` do?
A. Does in-place filtering
B. Both A and C
C. Returns a new DataFrame with condition
D. Filters rows using a query string
Direction: Choose the correct option

Q7.

How do you select rows by index label using `.loc`?
A. df.iloc[1:3]
B. df[1:3]
C. Both A and B
D. df.loc[1:3]
Direction: Choose the correct option

Q8.

What is the result of `df[df['score'].isna()]`?
A. All rows
B. Error
C. Rows with non-missing score
D. Rows with missing score
Direction: Choose the correct option

Q9.

How do you select a subset of columns while filtering rows?
A. df[df['age']>30][['name','age']]
B. Both A and B
C. df.loc[rows_condition, ['col1','col2']]
D. df.filter(items=['col1','col2']).query(condition)
Direction: Choose the correct option

Q10.

What does `df.nlargest(5, 'sales')` return?
A. First 5 rows
B. Sorted rows
C. Bottom 5 rows
D. Top 5 rows by 'sales' column