Loading

Quipoin Menu

Learn • Practice • Grow

python-for-ai / Merging and Joining
mcq
Direction: Choose the correct option

Q1.

How do you merge two DataFrames on a common column in pandas?
A. df1.merge(df2, on='key')
B. Both A and B
C. df1.join(df2, on='key')
D. pd.merge(df1, df2, on='key')
Direction: Choose the correct option

Q2.

What is the default type of join in `pd.merge()`?
A. Outer
B. Left
C. Right
D. Inner
Direction: Choose the correct option

Q3.

How do you perform a left join in pandas merge?
A. how='left'
B. join='left'
C. how='left'
D. how='left'
Direction: Choose the correct option

Q4.

What does `df1.join(df2, on='key')` assume about index?
A. Both on index
B. `df1` is joined on its index
C. `df2` is joined on its index
D. None
Direction: Choose the correct option

Q5.

What is the result of merging on columns with different names?
A. Use `merge` only with index
B. Use `on` with both
C. Error
D. Use `left_on` and `right_on` parameters
Direction: Choose the correct option

Q6.

How do you concatenate two DataFrames vertically (row-wise)?
A. df1.concat(df2)
B. pd.merge(df1, df2, axis=0)
C. pd.append(df1, df2)
D. pd.concat([df1, df2])
Direction: Choose the correct option

Q7.

What does `pd.concat([df1, df2], axis=1)` do?
A. Performs inner join
B. Error
C. Concatenates vertically
D. Concatenates horizontally (column-wise)
Direction: Choose the correct option

Q8.

How do you handle duplicate column names after merge?
A. Rename columns directly
B. Both A and B
C. Use `suffixes` parameter
D. Use `lsuffix` and `rsuffix`
Direction: Choose the correct option

Q9.

What is the output of `pd.merge(df1, df2, how='outer', indicator=True)`?
A. Drops missing
B. Only outer join
C. Error
D. Adds column '_merge' indicating source
Direction: Choose the correct option

Q10.

Which operation is used to combine DataFrames with overlapping indexes but different columns?
A. pd.concat(axis=1)
B. All of the above
C. df1.join(df2)
D. pd.merge