Recall & Review
beginner
What does the
merge() function do in pandas?The
merge() function combines two DataFrames based on common columns or indices, similar to SQL joins.Click to reveal answer
beginner
Name the four main types of joins you can perform with
merge().The four main join types are: inner, left, right, and outer joins.
Click to reveal answer
beginner
What is an inner join in
merge()?An inner join returns only rows with keys that appear in both DataFrames.
Click to reveal answer
intermediate
How do you specify the columns to join on in
merge()?Use the
on parameter to specify the column name(s) to join on. You can also use left_on and right_on for different column names.Click to reveal answer
beginner
What happens if you perform a
merge() without specifying the how parameter?By default,
merge() performs an inner join, returning only matching rows from both DataFrames.Click to reveal answer
Which
how parameter value returns all rows from the left DataFrame and matching rows from the right?✗ Incorrect
The 'left' join returns all rows from the left DataFrame and matching rows from the right.
If you want to join on columns with different names in each DataFrame, which parameters do you use?
✗ Incorrect
Use 'left_on' and 'right_on' to specify different column names to join on.
What type of join does
merge() perform by default?✗ Incorrect
By default, 'merge()' performs an inner join.
Which join type returns all rows from both DataFrames, filling missing values with NaN?
✗ Incorrect
An outer join returns all rows from both DataFrames, filling missing matches with NaN.
What parameter would you use to join DataFrames based on their index?
✗ Incorrect
Use 'left_index=True' and 'right_index=True' to join on indices.
Explain how you would use
merge() to combine two DataFrames with a common column named 'id'.Think about the simplest join on a shared column.
You got /4 concepts.
Describe the difference between an inner join and an outer join using
merge().Consider what happens to rows without matches.
You got /3 concepts.