Pandas dataframe to a dynamic nested JSON

后端 未结 3 941
萌比男神i
萌比男神i 2021-01-18 18:29

I want to create my dataframe which looks like this:

    employeeId  firstName   lastName    emailAddress    isDependent employeeIdTypeCode  entityCode  sour         


        
3条回答
  •  耶瑟儿~
    2021-01-18 19:20

    It sounds like the most sensible way to pull this off is:

    info_dict = df.set_index(['identifierValue', 'identifierValue']).to_dict('index')
    

    Then every time you get to profileInfo in your JSON, you can reference the info_dict above with the appropriate ('identifierValue', 'identifierValue')` key pair

    I'm confused about what your desired formatting is, but this is a start.

提交回复
热议问题