Dataframe pyspark to dict

前端 未结 3 1734
北恋
北恋 2021-01-15 19:22

I have this dataframe path_df:

path_df.show()
+---------------+-------------+----+
|FromComponentID|ToComponentID|Cost|
+---------------+-------------+----+
         


        
3条回答
  •  无人及你
    2021-01-15 19:33

    Easiest way I know is the below (but has Pandas dependency):

    path_df.toPandas().set_index('FromComponentID').T.to_dict('list')
    

提交回复
热议问题