I have this dataframe df.
| tweet_id | tweet_entites |
|---|---|
| 1223395611921305601 | [{'label': 'NORP', 'term': 'Chinese'}, {'label': 'ORG', 'term': 'InnoCare'}, {'label': 'GPE', 'term': 'Hong Kong'}] |
| 1223395868092465153 | NaN |
| 1223396204093902849 | [{'label': 'ORG', 'term': 'LIVE Press'}, {'label': 'ORG', 'term': 'Emergency Committee'}] |
| 1223396269655089154 | [{'label': 'CARDINAL', 'term': '83'}, {'label': 'CARDINAL', 'term': '2019nCoV'}, {'label': 'CARDINAL', 'term': '83'}] |
I want to extract the list-dictionary into separate columns as such:
| tweet_id | label | term |
|---|---|---|
| 1223395611921305601 | NORP | Chinese |
| 1223395611921305601 | ORG | InnoCare |
| 1223395611921305601 | GPE | Hong Kong |
| 1223395868092465153 | NaN | NaN |
| 1223396204093902849 | ORG | LIVE Press |
| 1223396204093902849 | ORG | Emergency Committee |
| 1223396269655089154 | CARDINAL | 83 |
| 1223396269655089154 | CARDINAL | 2019nCoV |
| 1223396269655089154 | CARDINAL | 83 |
The new columns will be named as label and term. I've seen references but I haven't been able to find one that is similar to the output that I want.