I have a dataframe that has a field called fields
which is a list of dicts (all rows have the same format). Here is how the dataframe is structured:
formId fields 123 [{'number': 1, 'label': 'Last Name', 'value': 'Doe'}, {'number': 2, 'label': 'First Name', 'value': 'John'}]
I am trying to unpack the fields
column so it looks like:
formId Last Name First Name 123 Doe John
The code I have currently is:
for i,r in df.iterrows(): for field in r['fields']: df.at[i, field['label']] = field['value']
However this does not seem like the most efficient way. Is there a better way to accomplish this?