In a PySpark application, I tried to transpose a dataframe by transforming it into pandas and then I want to write the result in csv file. This is how I am doing it:
df = df.toPandas().set_index("s").transpose()
df.coalesce(1).write.option("header", True).option("delimiter", ",").csv('dataframe')
When execution this script I get the following error:
'DataFrame' object has no attribute 'coalesce'
What is the problem? How can I fix it?