Construct pandas DataFrame from items in nested dictionary

后端 未结 5 1852
名媛妹妹
名媛妹妹 2020-11-22 10:49

Suppose I have a nested dictionary \'user_dict\' with structure:

  • Level 1: UserId (Long Integer)
  • Level 2: Category (S
5条回答
  •  孤街浪徒
    2020-11-22 10:59

    Building on verified answer, for me this worked best:

    ab = pd.concat({k: pd.DataFrame(v).T for k, v in data.items()}, axis=0)
    ab.T
    

提交回复
热议问题