Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam Certified Associate Developer for Apache Spark All Questions

View all questions & answers for the Certified Associate Developer for Apache Spark exam

Exam Certified Associate Developer for Apache Spark topic 1 question 40 discussion

The code block shown below contains an error. The code block is intended to print the schema of DataFrame storesDF. Identify the error.
Code block:
storesDF.printSchema

  • A. There is no printSchema member of DataFrame – schema and the print() function should be used instead.
  • B. The entire line needs to be a string – it should be wrapped by str().
  • C. There is no printSchema member of DataFrame – the getSchema() operation should be used instead.
  • D. There is no printSchema member of DataFrame – the schema() operation should be used instead.
  • E. The printSchema member of DataFrame is an operation and needs to be followed by parentheses.
Show Suggested Answer Hide Answer
Suggested Answer: E 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
jds0
4 months ago
Selected Answer: E
Option E is correct. Code example below: from pyspark.sql import SparkSession from pyspark.sql.functions import col, asc, desc from pyspark.errors import PySparkTypeError spark = SparkSession.builder.appName("MyApp").getOrCreate() data = [ (0, 43161, "A"), (1, 51200, "A"), (2, None, "B"), (3, 78367, "B"), (4, None, "C"), ] storesDF = spark.createDataFrame(data, ["storeID", "sqft", "division"]) storesDF.printSchema() # root # |-- storeID: long (nullable = true) # |-- sqft: long (nullable = true) # |-- division: string (nullable = true)
upvoted 1 times
...
4be8126
1 year, 6 months ago
Selected Answer: E
E. The printSchema member of DataFrame is an operation and needs to be followed by parentheses. The correct code block should be storesDF.printSchema() with parentheses to indicate that it's a method call.
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...