I have a csv file, which looks as follows:
Country/Region 1/22/20 1/23/20 1/24/20
Afghanistan 100 200 300
Albania 400 500 0
Algeria 20 30 70
(The table shows the amount of cases in certain date and country)
I want to convert it into a dictionary in the format shown bellow:
{
"Country1": {"time": [1/22/20, 1/23/20,...], "cases": [0, 0,...],
"Country2": {"time": [1/22/20, 1/23/20,...], "cases": [0, 0,...],
...
}
By using to_dict('records') looks very similar, but not the same.
[{'Country/Region': 'Afghanistan', '1/22/20': 0, '1/23/20': 0, '1/24/20': 0,...}]
I have been trying to use groupby('Country/Region') and it make no sense.
How would you do it?