Complete the code to select the 'name' column from the DataFrame.
df.select([1]).show()In Spark, to select a column by name, you pass the column name as a string to select().
Complete the code to filter rows where the 'age' column is greater than 30.
df.filter(df.age [1] 30).show()
The filter condition should check if 'age' is greater than 30, so use the '>' operator.
Fix the error in the code to filter rows where 'salary' is less than 50000.
df.where(df.salary [1] 50000).show()
The condition should be 'salary' less than 50000, so use the '<' operator.
Fill both blanks to create a dictionary comprehension that maps words to their lengths for words longer than 3 characters.
lengths = {word: [1] for word in words if len(word) [2] 3}The dictionary maps each word to its length, so the value is len(word). The filter keeps words longer than 3 characters, so use >.
Fill all three blanks to create a dictionary comprehension that maps uppercase words to their values for values greater than 0.
result = { [1]: [2] for k, v in data.items() if v [3] 0 }The keys are uppercase versions of k, so use k.upper(). The values are v. The filter keeps items where v is greater than 0, so use >.