Exam Certified Associate Developer for Apache Spark All QuestionsBrowse all questions from this exam
Question 163

Which of the following code blocks writes DataFrame storesDF to file path filePath as text files overwriting any existing files in that location?

    Correct Answer: E

    To write a DataFrame to a text file while overwriting any existing files, the correct method in PySpark is to use the combination of write(), mode(), and text() methods. The method write().mode('overwrite') sets the mode to overwrite any existing files, and the method text(filePath) specifies that the DataFrame should be written as a text file to the given file path. The correct syntax is storesDF.write().mode('overwrite').text(filePath).

Discussion
Sowwy1Option: B

B. storesDF.write.mode("overwrite").text(filePath)