0
0
Data Analysis Pythondata~5 mins

merge() for SQL-style joins in Data Analysis Python - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Aright
Bleft
Cinner
Douter
If you want to join on columns with different names in each DataFrame, which parameters do you use?
Aon
Bhow
Cindex
Dleft_on and right_on
What type of join does merge() perform by default?
Ainner
Bleft
Cright
Douter
Which join type returns all rows from both DataFrames, filling missing values with NaN?
Aouter
Bleft
Cright
Dinner
What parameter would you use to join DataFrames based on their index?
Aon
Bhow
Cleft_index and right_index
Dsort
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.