Complete the code to create a Spark DataFrame from a list.
data = [(1, 'Alice'), (2, 'Bob')] spark_df = spark.createDataFrame([1], ['id', 'name'])
The variable data holds the list of tuples to create the DataFrame.
Complete the code to apply a filter transformation on the DataFrame.
filtered_df = spark_df.filter(spark_df['id'] [1] 1)
The filter keeps rows where 'id' is greater than 1.
Fix the error in the code to trigger the lazy evaluation and show the results.
result = filtered_df.[1]()The show() action triggers the lazy evaluation and displays the DataFrame.
Fill both blanks to create a new DataFrame with selected columns and trigger computation.
selected_df = spark_df.[1]('name') selected_df.[2]()
select('name') picks the 'name' column, and show() triggers the computation and displays the data.
Fill all three blanks to create a filtered DataFrame, select a column, and count the rows.
filtered = spark_df.filter(spark_df['id'] [1] 1) selected = filtered.[2]('name') row_count = selected.[3]()
First, filter rows where 'id' is greater than 1, then select the 'name' column, and finally count the rows to trigger computation.