0
0
Pandasdata~10 mins

Outer join behavior in Pandas - 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 an outer join of df1 and df2 on the 'key' column.

Pandas
result = df1.merge(df2, on='key', how=[1])
Drag options to blanks, or click blank then click option'
Aouter
Bleft
Cright
Dinner
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'inner' join which only keeps matching rows.
Using 'left' or 'right' which keep only one side's rows.
2fill in blank
medium

Complete the code to merge df1 and df2 on columns 'key1' and 'key2' with an outer join.

Pandas
result = df1.merge(df2, on=[1], how='outer')
Drag options to blanks, or click blank then click option'
A'key1', 'key2'
B'key2'
C'key1'
D['key1', 'key2']
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a string with comma-separated keys instead of a list.
Passing only one key when two are needed.
3fill in blank
hard

Fix the error in the code to perform an outer join on 'id' column.

Pandas
result = df1.merge(df2, on=[1], how='outer')
Drag options to blanks, or click blank then click option'
A'id'
Bid
C['id']
Did'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the column name without quotes causing a NameError.
Using incorrect quotes or missing quotes.
4fill in blank
hard

Fill both blanks to create an outer join and fill missing values with 0.

Pandas
result = df1.merge(df2, on='key', how=[1]).fillna([2])
Drag options to blanks, or click blank then click option'
Aouter
B{0}
C0
Dinner
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'inner' join which excludes unmatched rows.
Passing 0 directly to fillna instead of a dictionary.
5fill in blank
hard

Fill all three blanks to perform an outer join on 'key', suffix overlapping columns with '_left' and '_right'.

Pandas
result = df1.merge(df2, on=[1], how=[2], suffixes=([3], '_right'))
Drag options to blanks, or click blank then click option'
A'key'
B'outer'
C'_left'
D'_common'
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the key name.
Using wrong join type.
Not providing suffixes as a tuple.