Complete the code to get the number of partitions in the DataFrame.
num_partitions = df.rdd.[1]The numPartitions property gives the number of partitions in the RDD underlying the DataFrame.
Complete the code to repartition the DataFrame into 4 partitions.
df_repart = df.[1](4)
coalesce which only reduces partitions without shuffle.partitionBy which is for writing files.The repartition() method reshuffles the data into the specified number of partitions.
Fix the error in the code to reduce partitions without full shuffle.
df_less = df.[1](2)
repartition which causes a full shuffle.partitionBy which is not for repartitioning in memory.The coalesce() method reduces the number of partitions without a full shuffle, making it efficient.
Fill both blanks to create a dictionary with word lengths for words longer than 3 characters.
lengths = {word: [1] for word in words if len(word) [2] 3}The dictionary comprehension maps each word to its length if the word length is greater than 3.
Fill all three blanks to create a dictionary with uppercase words as keys and their lengths as values for words longer than 4.
result = { [1]: [2] for w in words if len(w) [3] 4 }This dictionary comprehension creates keys as uppercase words and values as their lengths, filtering words longer than 4 characters.