I am working on a project for a job opportunity and it was asked to handle disease facts.I was running the code and the calculations worked just fine in Python and at some point, the results started the get an error "NAN" values.
I will display the code I've made :
- The code before the error :
# Calculation of the weight of the population by age#Uganda# Sum of observations from the column "Estimates, Uganda, 2019"total_observation = transposed_df["Estimates, Uganda, 2019"].sum()# The weight in percentage for each observationtransposed_df["Weight Percentage Uganda"] = (transposed_df["Estimates, Uganda, 2019"] / total_observation)##### #United tates of America# Sum of observations from the column "Estimates, Uganda, 2019"total_observation1 = transposed_df["Estimates, United States of America, 2019"].sum()# The weight in percentage for each observationtransposed_df["Weight Percentage United States of America"] = (transposed_df["Estimates, United States of America, 2019"] / total_observation1)#printtransposed_dfat this point, no Nan values on the outcome. I have checked out.
- The code where the error occurs:
#Age-standardized rate from Uganda transposed_df["Age-standardized rate from Uganda"] = (COPD["Death rate, Uganda, 2019"] * transposed_df["Weight Percentage Uganda"])#Age-standardized rate from United States of Americatransposed_df["Age-standardized rate from United States of America"] = (COPD["Death rate, United States, 2019"] * transposed_df["Weight Percentage United States of America"])#display resulttransposed_dfIt's a simple equation and the latest numbers started to break I don't know why. I also checked and at this point in the project, they became null values.I displayed the image where the error occurred.CHECK THE IMAGE OF THE TABLE HERE
Thanks in advance.
- I tried to find null values but they started to appear once I made the calculation and it's only on the latest results.
- Is not a division by zero, they are decimal values.
- Outcomes not provided, only in some rows.