Complete the code to create a Spark DataFrame from a list of tuples.
df = spark.createDataFrame([1], ['name', 'age'])
The createDataFrame method expects a list of tuples for data input.
Complete the code to select the 'age' column from the DataFrame.
ages = df.select([1])The select method requires the column name as a string.
Fix the error in the code to filter rows where age is greater than 25.
filtered_df = df.filter(df.age [1] 25)
The filter should keep rows where age is greater than 25, so use the '>' operator.
Fill both blanks to create a dictionary comprehension that maps names to ages for people older than 25.
{ [1]: [2] for row in filtered_df.collect() }Use row.name as the key and row.age as the value in the dictionary comprehension.
Fill all three blanks to create a new DataFrame with an added column 'age_plus_5' that adds 5 to the age.
new_df = df.withColumn('[1]', df.[2] [3] 5)
The new column is named 'age_plus_5', created by adding 5 to the 'age' column using the '+' operator.