QuestionQ284

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

Which of the following code blocks reads a CSV from the file path filePath into a DataFrame using the specified schema schema?

Explanation

In PySpark, spark.read returns a DataFrameReader; its schema(schema) method sets the input schema, and csv(filePath) loads the CSV data at that path into a DataFrame. The schema argument must be the schema object, not the literal string "schema".

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!