Complete the code to perform an inner join between two DataFrames df1 and df2 on the column 'id'.
joined_df = df1.join(df2, on='id', how='[1]')
The inner join returns only the rows with matching keys in both DataFrames.
Complete the code to perform a left join between df1 and df2 on the column 'user_id'.
joined_df = df1.join(df2, on='user_id', how='[1]')
The left join returns all rows from the left DataFrame (df1) and matched rows from the right DataFrame (df2). Unmatched right rows are null.
Fix the error in the code to perform a right join between dfA and dfB on 'key'.
result = dfA.join(dfB, on='key', how='[1]')
The right join keeps all rows from the right DataFrame (dfB) and matched rows from the left DataFrame (dfA). Unmatched left rows are null.
Fill both blanks to perform a full outer join between dfX and dfY on 'id' and select only rows where 'id' is not null.
joined = dfX.join(dfY, on='id', how='[1]') filtered = joined.filter(joined.id [2] None)
A full outer join keeps all rows from both DataFrames. Filtering with != None keeps rows where 'id' exists (not null).
Fill all three blanks to create a dictionary of user names and their ages from dfUsers where age is greater than 20.
user_dict = {row['[1]']: row['[2]'] for row in dfUsers.collect() if row['[3]'] > 20}This dictionary comprehension uses 'name' as keys and 'age' as values, filtering rows where 'age' is greater than 20.