Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Microsoft DP-750 Exam - Topic 3 Question 4 Discussion

You have an Azure Databricks workspace that is enabled for Unity Catalog and contains a Delta table named OrdersYou 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?
B) No
A) Yes

Microsoft DP-750 Exam - Topic 3 Question 4 Discussion

Actual exam question for Microsoft's DP-750 exam
Question #: 4
Topic #: 3
[All DP-750 Questions]

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?

Show Suggested Answer Hide Answer
Suggested Answer: B

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.


Contribute your Thoughts:

0/2000 characters
Cammy
3 days ago
I might be mistaken, but I believe the correct approach would be to use df.filter or df.where to remove those rows.
upvoted 0 times
...
Leonida
8 days ago
I'm not entirely sure, but I feel like fillna is more about replacing values rather than excluding rows.
upvoted 0 times
...
Michel
13 days ago
I remember a similar question where we had to filter out null values. I think we should use a filter or where clause instead.
upvoted 0 times
...
Lourdes
18 days ago
I think the solution doesn't meet the goal because fillna replaces nulls with 0 instead of excluding them.
upvoted 0 times
...

Save Cancel