owid / co2-data

Data on CO2 and greenhouse gas emissions by Our World in Data
https://ourworldindata.org/co2-and-other-greenhouse-gas-emissions
655 stars 219 forks source link

CO2 per capita reporting constant zero #1

Closed krueschan closed 3 years ago

krueschan commented 3 years ago

Hi there, The co2_per_capita column has the value of zero across all countries/regions and years in both the csv and xls files. I checked the python script but with my limited python debugging skills I didn't see anything obvious. Cheers, krueschan.

krueschan commented 3 years ago

ok. I've found the issue. the .mul function is applied to the object immediately preceding it. So in all cases where the term on the line above was a division, it is applied to the divisor, rather than the quotient, as expected. So using .mul(100) pushes the decimal point 2 places right instead of left as you would want when converting fractions to percentages. This also affected the share_global_cumulative_co2 variable, which is where I ended up discovering it, and many more. I figured it out because in share_global_co2 it worked fine because instead of .mul(100) you used * 100. Easy fix, I created a pull request for the patch. Peace, krueschan.