Recall & Review
beginner
What does merging on multiple keys mean in data analysis?
It means combining two tables or datasets by matching rows based on more than one column, like matching by both 'city' and 'year' together.
Click to reveal answer
beginner
How do you specify multiple keys when merging two pandas DataFrames?
You pass a list of column names to the 'on' parameter, like df1.merge(df2, on=['key1', 'key2']).
Click to reveal answer
intermediate
What happens if the keys you merge on have different names in the two DataFrames?
You use 'left_on' and 'right_on' parameters to specify the key columns separately for each DataFrame.
Click to reveal answer
beginner
Why is merging on multiple keys useful?
It helps to join data more precisely when one key alone is not enough to uniquely identify matching rows.
Click to reveal answer
beginner
What type of join can you perform when merging on multiple keys?
You can perform inner, left, right, or outer joins, just like merging on a single key.
Click to reveal answer
How do you merge two DataFrames on columns 'A' and 'B' in pandas?
✗ Incorrect
You must pass a list of column names to the 'on' parameter.
If the key columns have different names in two DataFrames, which parameters do you use?
✗ Incorrect
Use 'left_on' for the left DataFrame keys and 'right_on' for the right DataFrame keys.
What join type returns only rows with matching keys in both DataFrames?
✗ Incorrect
Inner join returns rows where keys match in both DataFrames.
Why merge on multiple keys instead of just one?
✗ Incorrect
Multiple keys help uniquely identify matching rows.
What happens if you merge on keys that do not exist in both DataFrames?
✗ Incorrect
Pandas raises a KeyError if keys are missing.
Explain how to merge two DataFrames on multiple keys with different column names.
Think about specifying keys separately for each DataFrame.
You got /4 concepts.
Describe why merging on multiple keys can improve data matching accuracy.
Consider when one key alone is not enough.
You got /3 concepts.