Current table:
| source | target | value | group |
|---|---|---|---|
| Bob | dog | 3 | 1 |
| Kate | cat | 4 | 2 |
| Sasha | whale | 5 | 3 |
Desired output:
list_dicts = [{'id': 'Bob', 'group': 1}, {'id':'Kate', 'group':2}, {'id': 'Sasha', 'group': 3},
{'id': 'dog', 'group': 1}, {'id': 'cat', 'group': 2}, {'id': 'whale', 'group': 3}]
For the moment I am only able to do this:
df = df.to_dict('records')
I assume that to go further, I'd have to select the columns which I want to transform into list of dictionaries ? In this case I do not need the "value" column. #sendhelp