Complete the code to repartition the DataFrame to reduce data skew.
df = df.[1](numPartitions=10)
Using repartition redistributes data across partitions to help reduce skew.
Complete the code to add a random salt column to the DataFrame to help with skew.
from pyspark.sql.functions import rand df = df.withColumn('salt', (rand() * [1]).cast('int'))
Adding a salt with 10 buckets helps distribute skewed keys into multiple groups.
Fix the error in the join to handle skew by joining on salted keys.
from pyspark.sql.functions import rand df1 = df1.withColumn('salt', (rand() * 10).cast('int')) df2 = df2.withColumn('salt', (rand() * 10).cast('int')) joined = df1.join(df2, ['key', [1]])
The join must include the 'salt' column to distribute skewed keys properly.
Fill both blanks to create a salted key and join on it to handle skew.
from pyspark.sql.functions import concat, col, lit df1 = df1.withColumn('salted_key', concat(col('key'), lit('_'), col([1]).cast('string'))) df2 = df2.withColumn('salted_key', concat(col('key'), lit('_'), col([2]).cast('string'))) joined = df1.join(df2, 'salted_key')
Both DataFrames use the 'salt' column to create a combined salted key for joining.
Fill both blanks to create a dictionary of word lengths for words longer than 3 characters.
lengths = {word: [1] for word in words if len(word) [2] 3}This dictionary comprehension maps each word to its length only if the word length is greater than 3.
