0
0
Pandasdata~10 mins

Inner 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 inner join of df1 and df2 on the 'key' column.

Pandas
result = df1.merge(df2, on=[1])
Drag options to blanks, or click blank then click option'
A'value'
B'index'
C'key'
D'id'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a column name that does not exist in both dataframes.
Using 'index' when the join is not on the index.
2fill in blank
medium

Complete the code to specify the type of join as inner explicitly.

Pandas
result = df1.merge(df2, on='key', how=[1])
Drag options to blanks, or click blank then click option'
A'outer'
B'inner'
C'left'
D'right'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'outer' or 'left' which include non-matching rows.
Using 'right' which joins differently.
3fill in blank
hard

Fix the error in the code to join df1 and df2 on 'key' with inner join.

Pandas
result = df1.merge(df2, on=[1], how='inner')
Drag options to blanks, or click blank then click option'
A'name'
B'index'
C'value'
D'key'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a column that does not exist in both dataframes.
Using 'index' when not joining on index.
4fill in blank
hard

Fill both blanks to join df1 and df2 on 'key' and keep only matching rows.

Pandas
result = df1.merge(df2, on=[1], how=[2])
Drag options to blanks, or click blank then click option'
A'key'
B'inner'
C'outer'
D'left'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'outer' or 'left' join which keep non-matching rows.
Using wrong column names.
5fill in blank
hard

Fill all three blanks to join df1 and df2 on 'key', keep matching rows, and suffix overlapping columns with '_left' and '_right'.

Pandas
result = df1.merge(df2, on=[1], how=[2], suffixes=([3]))
Drag options to blanks, or click blank then click option'
A'key'
B'inner'
C'_left', '_right'
D'_x', '_y'
Attempts:
3 left
💡 Hint
Common Mistakes
Not specifying suffixes causing column name conflicts.
Using wrong join type or column.