Microsoft
DP-700 · Question #100
You have a table in a Fabric lakehouse that contains the following data: | SalesOrderNumber | OrderDate | CustomerName | Email | |------------------|------------|----------------|---------------------
Sign in or unlock DP-700 to reveal the answer and full explanation for question #100. The question stem and answer options stay visible for context.
Design and implement data ingestion and transformation
Question
You have a table in a Fabric lakehouse that contains the following data:
You have a notebook that contains the following code segment:
| SalesOrderNumber | OrderDate | CustomerName | |
|---|---|---|---|
| SO49172 | 2021-01-01 | Brian Howard | [email protected] |
| SO49173 | 2021-01-01 | Linda Alvarez | [email protected] |
| SO49174 | 2021-01-01 | Gina Hernandez | [email protected] |
| SO49178 | 2021-01-01 | Beth Ruiz | [email protected] |
| SO49179 | 2021-01-01 | Evan Ward | [email protected] |
01 df = df.withColumn('CustomerName', when(col('CustomerName').isNull() | (col('CustomerName')==''), lit('Unknown')).otherwise(col('CustomerName')))
02 df = df.withColumn('Username', split(col('Email'), '@').getItem(0))
03 df = df.dropDuplicates(['OrderDate']).selectExpr('*', "year(OrderDate') as Year", "('CustomerName') as Username")
04 display(df.head(10))
For each of the following statements, select Yes if the statement is true. Otherwise, select No. NOTE: Each correct selection is worth one point.
Statements:
- Line 01 will replace all the null and empty values in the CustomerName column with the Unknown value.
- Line 02 will extract the value before the @ character and generate a new column named Username.
- Line 03 will extract the year value from the OrderDate column and keep only the first occurrence for each year.
Exhibit
Unlock DP-700 to see the answer
You've previewed enough free DP-700 questions. Unlock DP-700 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.
Topics
#PySpark#DataFrame Operations#Data Cleaning#Data Transformation
