You have an Azure Databricks workspace that is enabled for Unity Catalog and contains a Delta table named Orders
You load the Orders table into an Apache Spark DataFrame named df.
You need to create a DataFrame that excludes rows where the order amount is null.
Solution: You run the following expression.
df-fillna(0, subset=['order_amount'])
Does this meet the goal?
CORRECT ANSWE R: B - No.
According to Microsoft Learn on PySpark DataFrame operations, df.fillna(0, subset=['order_amount']) replaces null values in the order_amount column with the integer 0. This does NOT exclude rows where order_amount is null --- it replaces the null with 0, meaning those rows are still included in the resulting DataFrame with 0 as the order_amount value. The requirement is to 'create a DataFrame that excludes rows where the order_amount is null' --- which means null rows must be removed (dropped), not filled. The correct operation to exclude null rows is df.dropna(subset=['order_amount']) or df.filter(df.order_amount.isNotNull()). fillna is used for data imputation (replacing nulls with a default value), which is a different operation from filtering out null rows.
Cammy
3 days agoLeonida
8 days agoMichel
13 days agoLourdes
18 days ago