0
0
Data Analysis Pythondata~10 mins

Inner 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 an inner join of two DataFrames on the 'id' column.

Data Analysis Python
result = df1.merge(df2, on=[1])
Drag options to blanks, or click blank then click option'
A'name'
B'age'
C'id'
D'date'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a column name that does not exist in both DataFrames.
Forgetting to put quotes around the column name.
2fill in blank
medium

Complete the code to perform an inner join and keep only rows with matching keys.

Data Analysis Python
joined = df1.merge(df2, on='id', how=[1])
Drag options to blanks, or click blank then click option'
A'inner'
B'left'
C'outer'
D'right'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'left' or 'right' which keep unmatched rows from one side.
Using 'outer' which keeps all rows from both DataFrames.
3fill in blank
hard

Fix the error in the code to correctly perform an inner join on 'user_id'.

Data Analysis Python
result = df1.merge(df2, on=[1])
Drag options to blanks, or click blank then click option'
A'userid'
B'id'
C'userId'
D'user_id'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a column name with wrong case or spelling.
Using a column name that exists only in one DataFrame.
4fill in blank
hard

Fill both blanks to perform an inner join on 'order_id' and keep only matching rows.

Data Analysis Python
joined = df_orders.merge(df_customers, on=[1], how=[2])
Drag options to blanks, or click blank then click option'
A'order_id'
B'inner'
C'outer'
D'customer_id'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'customer_id' instead of 'order_id' as join key.
Using 'outer' join which keeps unmatched rows.
5fill in blank
hard

Fill all three blanks to perform an inner join on 'product_id', rename the joined column, and keep only matching rows.

Data Analysis Python
result = df1.merge(df2, on=[1], how=[2]).rename(columns=[3])
Drag options to blanks, or click blank then click option'
A'product_id'
B'inner'
C{'price_y': 'price'}
D'price_x'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong join column.
Using 'outer' or other join types instead of 'inner'.
Not renaming the duplicate column causing confusion.