Convert Pyspark Dataframe Into List Of Python Dictionaries
Hi I'm new to pyspark and I'm trying to convert pyspark.sql.dataframe into list of dictionaries. Below is my dataframe, the type is :
Solution 1:
You can map each row into a dictionary and collect the results:
df.rdd.map(lambda row: row.asDict()).collect()
Post a Comment for "Convert Pyspark Dataframe Into List Of Python Dictionaries"