Microsoft
DP-700 · Question #100
You have a table in a Fabric lakehouse that contains the following data: | SalesOrderNumber | OrderDate | CustomerName | Email |…
Statement 1: Line 01 will replace all the null and empty values in the CustomerName column with the Unknown value. Answer: Yes. Statement 2: Line 02 will extract the value before the @ character and generate a new column named Username. Answer: Yes. Statement 3: Line 03 will…
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
Explanation
Statement 1: Line 01 will replace all the null and empty values in the CustomerName column with the Unknown value. Answer: Yes. Statement 2: Line 02 will extract the value before the @ character and generate a new column named Username. Answer: Yes. Statement 3: Line 03 will extract the year value from the OrderDate column and keep only the first occurrence for each year. Answer: No.
Topics
#PySpark#DataFrame Operations#Data Cleaning#Data Transformation
Community Discussion
No community discussion yet for this question.
