Recall & Review
beginner
What does the pandas
merge() function do?It combines two DataFrames based on common columns or indices, similar to SQL joins.
Click to reveal answer
beginner
What are the main types of joins you can perform with
merge()?- Inner join: keeps only matching rows
- Left join: keeps all rows from left DataFrame
- Right join: keeps all rows from right DataFrame
- Outer join: keeps all rows from both DataFrames
Click to reveal answer
beginner
How do you specify the columns to join on in
merge()?Use the
on parameter with a column name or list of column names that exist in both DataFrames.Click to reveal answer
beginner
What happens if you use
how='left' in merge()?All rows from the left DataFrame are kept. Matching rows from the right DataFrame are added. If no match, right side columns have NaN.
Click to reveal answer
intermediate
What is the difference between
merge() and concat() in pandas?merge() joins DataFrames based on keys (like SQL joins). concat() stacks DataFrames vertically or horizontally without matching keys.Click to reveal answer
Which
how parameter in merge() keeps only rows that appear in both DataFrames?✗ Incorrect
The 'inner' join keeps only rows with matching keys in both DataFrames.
If you want to keep all rows from the right DataFrame and add matching rows from the left, which
how do you use?✗ Incorrect
The 'right' join keeps all rows from the right DataFrame and matches from the left.
What parameter do you use to specify the column(s) to join on in
merge()?✗ Incorrect
The 'on' parameter specifies the column(s) to join on.
What will be the result of an outer join?
✗ Incorrect
An outer join keeps all rows from both DataFrames, filling missing matches with NaN.
Which pandas function stacks DataFrames without matching keys?
✗ Incorrect
concat() stacks DataFrames vertically or horizontally without matching keys.Explain how to use pandas
merge() to combine two DataFrames with a left join.Think about keeping all rows from the first DataFrame and matching from the second.
You got /4 concepts.
Describe the difference between inner join and outer join in pandas
merge().Consider which rows are kept in each join type.
You got /3 concepts.