I'm wondering how to flatten the nested pandas dataframe as demonstrated in the picture attached.
The nested attribute is given by 'data' field. In short: I have a list of participants (denoted by 'participant_id') and they submitted responses ('data') at different times. I need to create the wide dataframe, where for each participant at each time stamp there is a row of records of their data ('q1', 'q2',...,'summary')
Many thanks in advance!
Try this:
pd.concat([df.data.apply(pd.Series), df.drop('data', axis=1)], axis=1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With