python pandas dataframe columns convert to dict key and value

后端 未结 3 785
情歌与酒
情歌与酒 2020-11-30 18:15

I have a pandas data frame with multiple columns and I would like to construct a dict from two columns: one as the dict\'s keys and the other as the dict\'s values. How can

3条回答
  •  自闭症患者
    2020-11-30 19:04

    With pandas it can be done as:

    If lakes is your DataFrame:

    area_dict = lakes.to_dict('records')
    

提交回复
热议问题