I have a Pandas df which contains daily average tempreature of 3 countries:
date | country | temp |
---|---|---|
1/1/19 | US | 18 |
1/1/19 | GB | 21 |
1/1/19 | AU | 26 |
2/1/19 | US | 19 |
2/1/19 | GB | 19 |
2/1/19 | AU | 30 |
3/1/19 | GB | 16 |
3/1/19 | AU | 30 |
4/1/19 | GB | 20 |
4/1/19 | US | 20 |
I am trying to create a transformation whereby I can arrnage all the countries in a separate row based on the date, taking into account missing values like so:
date | US | GB | AU |
---|---|---|---|
1/1/19 | 18 | 21 | 26 |
2/1/19 | 19 | 19 | 30 |
3/1/19 | 16 | 30 | |
4/1/19 | 20 | 20 |
What would be the fastest way to acheive this? Is there a fatser way with numpy?