DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK · Question #76
The code block shown below should print the schema of DataFrame storesDF. Choose the response that correctly fills in the numbered blanks within the code block to complete this task. Code block…
The correct answer is E. 1. storesDF. The correct method to print a DataFrame's schema is storesDF.printSchema(). This prints the schema as a formatted tree showing each column's name, data type, and nullability (e.g., |-- division: string (nullable = true)). The property storesDF.schema also exists but returns a…
Question
The code block shown below should print the schema of DataFrame storesDF. Choose the response that correctly fills in the numbered blanks within the code block to complete this task. Code block:
1.2
Options
- A
- storesDF
- B
- storesDF
- C
- storesDF
- D
- storesDF
- E
- storesDF
How the community answered
(27 responses)- C7% (2)
- D4% (1)
- E89% (24)
Explanation
The correct method to print a DataFrame's schema is storesDF.printSchema(). This prints the schema as a formatted tree showing each column's name, data type, and nullability (e.g., |-- division: string (nullable = true)). The property storesDF.schema also exists but returns a StructType object rather than printing anything. Option E fills in blank 2 with printSchema(), which is the only method in the Spark DataFrame API that produces printed schema output.
Topics
Community Discussion
No community discussion yet for this question.