0
0
Data Analysis Pythondata~10 mins

Outer join in Data Analysis Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to perform a left outer join of DataFrame df1 with df2 on the 'id' column.

Data Analysis Python
result = df1.merge(df2, how=[1], on='id')
Drag options to blanks, or click blank then click option'
A'left'
B'inner'
C'right'
D'cross'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'inner' join which only keeps matching rows.
Using 'right' join which keeps all rows from df2 instead of df1.
2fill in blank
medium

Complete the code to perform a full outer join of DataFrame df1 with df2 on the 'key' column.

Data Analysis Python
result = df1.merge(df2, how=[1], on='key')
Drag options to blanks, or click blank then click option'
A'right'
B'inner'
C'left'
D'outer'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'inner' join which excludes unmatched rows.
Using 'left' or 'right' which keep only one side's rows.
3fill in blank
hard

Fix the error in the code to perform a right outer join on 'user_id'.

Data Analysis Python
joined = df1.merge(df2, how=[1], on='user_id')
Drag options to blanks, or click blank then click option'
A'left'
B'right'
C'inner'
D'outer'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'left' join which keeps rows from the first DataFrame.
Using 'inner' join which excludes unmatched rows.
4fill in blank
hard

Fill both blanks to create a left outer join on 'order_id' and include suffixes '_left' and '_right' for overlapping columns.

Data Analysis Python
result = df_orders.merge(df_payments, how=[1], on=[2], suffixes=('_left', '_right'))
Drag options to blanks, or click blank then click option'
A'left'
B'right'
C'order_id'
D'payment_id'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong join type like 'right'.
Joining on the wrong column like 'payment_id'.
5fill in blank
hard

Fill all three blanks to perform a full outer join on 'emp_id' with suffixes '_emp' and '_dept'.

Data Analysis Python
final = employees.merge(departments, how=[1], on=[2], suffixes=[3])
Drag options to blanks, or click blank then click option'
A'outer'
B'emp_id'
C('_emp', '_dept')
D'emp_id', 'dept_id'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong join type like 'inner'.
Joining on multiple columns incorrectly.
Not using suffixes or using wrong format.