I have a data with a country
, year
and value
column. the max(year) is 1985 and min(year) is 2016 but not all country have data of all year(1985-2016). So to plot comparable bar plot between countries, I want to add value
0 for missing year for each country.
for example:
df -->
country year value
0 India 2040 354
1 India 2041 357
2 India 2042 454
3 USA 2040 454
4 USA 2041 436
As USA don't have 2042 data so adding it result into:
country year value
0 India 2040 354
1 India 2041 357
2 India 2042 454
3 USA 2040 454
4 USA 2041 436
5 USA 2042 0
How to do it for each country in my data?
max(year)
as far as I can see is 2042. Am I missing something?