You can use this:
df.write
  .option("header", "true")
  .csv("<path to the directory>/out.csv")
You can also convert the whole data frame like this:
df.coalesce(1).write
    .format("com.databricks.spark.csv")
    .option("header", "true")
    .save("<path to the directory>/out.csv")