How to Save PySpark Dataframe to a Single Output File
Save a Spark dataframe to a single output csv file
Save a Spark dataframe to a single output csv file
There is no obvious way to save the nicely formatted DataFrame show() string to a variable. But here is how you can do it
How to unit test PySpark code using Pytest