Given two dataframes df1 and df2, what is the result of the inner join on column key?
import pandas as pd df1 = pd.DataFrame({'key': ['A', 'B', 'C'], 'val1': [1, 2, 3]}) df2 = pd.DataFrame({'key': ['B', 'C', 'D'], 'val2': [4, 5, 6]}) result = pd.merge(df1, df2, on='key', how='inner') print(result)
Inner join returns only rows with matching keys in both dataframes.
The inner join keeps only keys present in both df1 and df2. Here, keys 'B' and 'C' are common.
Choose the correct description of an inner join operation between two tables or dataframes.
Think about which rows appear in the result when keys do not match.
An inner join returns only rows with keys present in both tables, excluding rows without matches.
Which of the following code snippets correctly performs an inner join on column id between df_left and df_right?
Recall the correct function and parameter names for pandas merge.
The pd.merge() function with how='inner' and on='id' is the correct syntax.
You have two large dataframes with millions of rows each. Which approach can improve the performance of an inner join on column user_id?
Indexes can speed up join operations.
Setting the join key as index allows pandas to use faster join algorithms internally.
Given the code below, why is the result of the inner join empty?
import pandas as pd df1 = pd.DataFrame({'key': ['a', 'b', 'c'], 'val': [1, 2, 3]}) df2 = pd.DataFrame({'key': ['A', 'B', 'C'], 'val': [4, 5, 6]}) result = pd.merge(df1, df2, on='key', how='inner') print(result)
Check if the keys match exactly including letter case.
Inner join matches keys exactly. Here, lowercase and uppercase letters differ, so no rows match.