Recall & Review
beginner
What does merging on index mean in pandas?
Merging on index means combining two data tables using their row labels (index) instead of columns. It matches rows based on their index values.
Click to reveal answer
beginner
How do you merge two DataFrames on their indexes in pandas?
Use the pandas merge function with the parameters left_index=True and right_index=True to merge on the indexes of both DataFrames.
Click to reveal answer
intermediate
What is the difference between merging on columns and merging on index?
Merging on columns uses matching values in specified columns to combine rows, while merging on index uses the row labels (index) to match rows.
Click to reveal answer
intermediate
What happens if indexes do not match when merging on index?
Rows with indexes that do not match will be included or excluded depending on the type of merge (inner, outer, left, right). Non-matching rows may have missing values.
Click to reveal answer
beginner
Write a simple pandas code snippet to merge two DataFrames df1 and df2 on their indexes.
merged = df1.merge(df2, left_index=True, right_index=True)
Click to reveal answer
Which parameters do you set to True to merge two DataFrames on their indexes?
✗ Incorrect
To merge on indexes, set left_index=True and right_index=True in pandas merge.
What type of merge includes all rows from both DataFrames, matching where possible?
✗ Incorrect
An outer merge includes all rows from both DataFrames, filling missing matches with NaN.
If you want to merge on a column instead of index, which parameter do you use?
✗ Incorrect
Use on='column_name' to merge on a specific column.
What will happen if indexes do not match in an inner merge on index?
✗ Incorrect
Inner merge keeps only rows with matching indexes.
Which pandas function is used to merge DataFrames?
✗ Incorrect
The merge() function is used to combine DataFrames based on columns or indexes.
Explain how to merge two pandas DataFrames on their indexes and what parameters are needed.
Think about how row labels are used instead of columns.
You got /4 concepts.
Describe the difference between merging on columns and merging on index in pandas.
Consider what pandas uses to align rows in each case.
You got /4 concepts.