Which of the following code blocks writes DataFrame storesDF to file path filePath as text files overwriting any existing files in that location?
Which of the following code blocks writes DataFrame storesDF to file path filePath as text files overwriting any existing files in that location?
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).
B. storesDF.write.mode("overwrite").text(filePath)