0
0
Apache Sparkdata~10 mins

Understanding partitions in Apache Spark - Interactive Quiz & Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to get the number of partitions in the DataFrame.

Apache Spark
num_partitions = df.rdd.[1]
Drag options to blanks, or click blank then click option'
Acount
BgetNumPartitions
Cpartitions
DnumPartitions
Attempts:
3 left
💡 Hint
Common Mistakes
Using a method name instead of the property.
Trying to call a method that doesn't exist.
2fill in blank
medium

Complete the code to repartition the DataFrame into 4 partitions.

Apache Spark
df_repart = df.[1](4)
Drag options to blanks, or click blank then click option'
ApartitionBy
Bcoalesce
Crepartition
Dsplit
Attempts:
3 left
💡 Hint
Common Mistakes
Using coalesce which only reduces partitions without shuffle.
Using partitionBy which is for writing files.
3fill in blank
hard

Fix the error in the code to reduce partitions without full shuffle.

Apache Spark
df_less = df.[1](2)
Drag options to blanks, or click blank then click option'
Acoalesce
BpartitionBy
Crepartition
Dsplit
Attempts:
3 left
💡 Hint
Common Mistakes
Using repartition which causes a full shuffle.
Using partitionBy which is not for repartitioning in memory.
4fill in blank
hard

Fill both blanks to create a dictionary with word lengths for words longer than 3 characters.

Apache Spark
lengths = {word: [1] for word in words if len(word) [2] 3}
Drag options to blanks, or click blank then click option'
Alen(word)
B>
C<
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself as the value instead of its length.
Using the wrong comparison operator.
5fill in blank
hard

Fill all three blanks to create a dictionary with uppercase words as keys and their lengths as values for words longer than 4.

Apache Spark
result = { [1]: [2] for w in words if len(w) [3] 4 }
Drag options to blanks, or click blank then click option'
Aw.upper()
Blen(w)
C>
Dw.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase instead of uppercase for keys.
Using the wrong comparison operator.
Swapping keys and values.