Annual death rates in people of different ages, by sex world

Author

math4mad

Code
include("utils.jl")
[ Info: loading success
"Entity", "Code", "Year", "Central death rate - Type: period - Sex: female - Age: 0", "Central death rate - Type: period - Sex: male - Age: 0", "Central death rate - Type: period - Sex: female - Age: 10", "Central death rate - Type: period - Sex: male - Age: 10", "Central death rate - Type: period - Sex: female - Age: 15", "Central death rate - Type: period - Sex: male - Age: 15", "Central death rate - Type: period - Sex: female - Age: 25", "Central death rate - Type: period - Sex: male - Age: 25", "Central death rate - Type: period - Sex: female - Age: 45", "Central death rate - Type: period - Sex: male - Age: 45", "Central death rate - Type: period - Sex: female - Age: 65", "Central death rate - Type: period - Sex: male - Age: 65", "Central death rate - Type: period - Sex: female - Age: 80", "Central death rate - Type: period - Sex: male - Age: 80"]

2. load data->dataframe

Code
df=@pipe CSV.File("./data/annual-death-rates-in-different-age-groups-by-sex.csv")|>DataFrame
19922×17 DataFrame
19897 rows omitted
Row Entity Code Year Central death rate - Type: period - Sex: female - Age: 0 Central death rate - Type: period - Sex: male - Age: 0 Central death rate - Type: period - Sex: female - Age: 10 Central death rate - Type: period - Sex: male - Age: 10 Central death rate - Type: period - Sex: female - Age: 15 Central death rate - Type: period - Sex: male - Age: 15 Central death rate - Type: period - Sex: female - Age: 25 Central death rate - Type: period - Sex: male - Age: 25 Central death rate - Type: period - Sex: female - Age: 45 Central death rate - Type: period - Sex: male - Age: 45 Central death rate - Type: period - Sex: female - Age: 65 Central death rate - Type: period - Sex: male - Age: 65 Central death rate - Type: period - Sex: female - Age: 80 Central death rate - Type: period - Sex: male - Age: 80
String String15? Int64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64
1 Afghanistan AFG 1950 328.053 378.814 7.72991 6.52991 9.96758 8.11575 15.0426 14.8812 21.2739 27.5066 67.6107 77.0253 211.223 226.547
2 Afghanistan AFG 1951 324.777 374.956 7.65714 6.47173 9.87427 8.0444 14.9049 14.7495 21.0961 27.2708 67.1116 76.5053 209.885 225.159
3 Afghanistan AFG 1952 318.286 366.965 7.51281 6.3596 9.6892 7.90725 14.6317 14.4965 20.7428 26.8212 66.1187 75.5487 207.22 222.703
4 Afghanistan AFG 1953 311.888 358.685 7.37038 6.25279 9.50655 7.77702 14.3619 14.2566 20.3934 26.3985 65.1349 74.6933 204.573 220.633
5 Afghanistan AFG 1954 305.975 351.087 7.47033 6.32612 9.54872 7.80432 14.3075 14.1708 20.3094 26.2079 64.6866 74.327 202.837 219.442
6 Afghanistan AFG 1955 298.864 342.552 7.08519 6.0428 9.14193 7.52088 13.824 13.7848 19.7027 25.5661 63.2202 72.9975 199.518 216.517
7 Afghanistan AFG 1956 292.437 334.788 6.9579 5.95098 8.97388 7.40485 13.5696 13.5633 19.3775 25.173 62.3198 72.1939 197.145 214.542
8 Afghanistan AFG 1957 285.96 327.082 6.80497 5.82437 8.78425 7.25426 13.2964 13.2944 19.0277 24.7002 61.3636 71.1901 194.668 212.095
9 Afghanistan AFG 1958 279.403 319.298 6.66214 5.69684 8.60189 7.09851 13.0273 13.0086 18.6822 24.1954 60.4097 70.1002 192.166 209.401
10 Afghanistan AFG 1959 273.273 312.183 6.52603 5.58004 8.42824 6.9558 12.7715 12.7468 18.3544 23.7325 59.5094 69.0955 189.867 206.911
11 Afghanistan AFG 1960 267.463 305.598 6.40648 5.48074 8.27133 6.83256 12.5389 12.5175 18.0579 23.3241 58.6735 68.2023 187.792 204.59
12 Afghanistan AFG 1961 261.854 298.886 6.26721 5.3612 8.09831 6.68825 12.2866 12.256 17.7335 22.8633 57.8106 67.1957 185.652 202.185
13 Afghanistan AFG 1962 256.655 292.773 6.14919 5.26366 7.9478 6.56954 12.0652 12.0384 17.4491 22.4812 57.0294 66.3898 183.704 200.26
19911 Zimbabwe ZWE 2010 53.9416 60.8736 1.63101 1.90256 2.49942 2.61754 8.802 8.97857 20.8596 27.2927 45.8422 52.5112 86.3175 114.257
19912 Zimbabwe ZWE 2011 50.7671 57.5466 1.5059 1.7603 2.24074 2.40589 6.98757 7.8604 16.663 23.4714 41.1328 49.1328 85.6723 113.942
19913 Zimbabwe ZWE 2012 45.8417 52.3628 1.2744 1.53946 1.90764 2.12629 5.97021 6.73963 14.7873 20.558 37.6887 46.8993 85.0377 113.63
19914 Zimbabwe ZWE 2013 42.4171 48.8878 1.14827 1.36861 1.71382 1.9229 5.13833 5.92327 13.1951 18.2398 35.8164 45.3136 84.4419 113.357
19915 Zimbabwe ZWE 2014 40.2433 46.6497 1.06513 1.26043 1.58333 1.78416 4.57123 5.31936 12.052 16.3566 34.5043 43.8205 83.7835 113.008
19916 Zimbabwe ZWE 2015 39.3862 45.7603 1.03008 1.21829 1.51606 1.7263 4.23604 5.0488 11.3024 15.4633 33.6349 43.0445 83.1682 112.702
19917 Zimbabwe ZWE 2016 37.7949 44.0875 0.97629 1.14752 1.43611 1.64832 3.93881 4.80345 10.7236 14.872 32.8932 42.7217 82.5508 112.388
19918 Zimbabwe ZWE 2017 36.8661 43.1389 0.95685 1.12218 1.38986 1.61538 3.73174 4.70667 10.2912 14.6938 32.3443 42.7099 81.9914 112.102
19919 Zimbabwe ZWE 2018 35.4646 41.6297 0.89795 1.04302 1.32043 1.53221 3.51856 4.42719 9.86634 13.892 31.726 42.13 81.3326 111.776
19920 Zimbabwe ZWE 2019 35.3383 41.4167 0.93255 1.07613 1.32845 1.55651 3.48048 4.53653 9.78645 14.3989 31.6513 42.7631 80.8855 111.541
19921 Zimbabwe ZWE 2020 34.9539 40.9834 0.87637 1.02782 1.20826 1.39351 3.11532 4.14614 9.38663 15.0135 33.6533 48.0212 82.9557 120.98
19922 Zimbabwe ZWE 2021 34.9083 40.922 0.86883 1.02383 1.30698 1.58042 3.38878 4.70133 10.5541 17.1106 38.6799 56.6425 100.369 143.754
Code
cats=names(df)
rename!(df,  "Central death rate - Type: period - Sex: female - Age: 0"=>:female_age0, 
             "Central death rate - Type: period - Sex: male - Age: 0"=>:male_age0, 
             "Central death rate - Type: period - Sex: female - Age: 10"=>:female_age10, 
             "Central death rate - Type: period - Sex: male - Age: 10"=>:male_age10, 
             "Central death rate - Type: period - Sex: female - Age: 15"=>:female_age15, 
             "Central death rate - Type: period - Sex: male - Age: 15"=>:male_age15, 
             "Central death rate - Type: period - Sex: female - Age: 25"=>:female_age25, 
             "Central death rate - Type: period - Sex: male - Age: 25"=>:male_age25, 
             "Central death rate - Type: period - Sex: female - Age: 45"=>:female_age45, 
             "Central death rate - Type: period - Sex: male - Age: 45"=>:male_age45,
              "Central death rate - Type: period - Sex: female - Age: 65"=>:female_age65, 
              "Central death rate - Type: period - Sex: male - Age: 65"=>:male_age65, 
              "Central death rate - Type: period - Sex: female - Age: 80"=>:female_age80, 
              "Central death rate - Type: period - Sex: male - Age: 80" =>:male_age80 
)
19922×17 DataFrame
19897 rows omitted
Row Entity Code Year female_age0 male_age0 female_age10 male_age10 female_age15 male_age15 female_age25 male_age25 female_age45 male_age45 female_age65 male_age65 female_age80 male_age80
String String15? Int64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64
1 Afghanistan AFG 1950 328.053 378.814 7.72991 6.52991 9.96758 8.11575 15.0426 14.8812 21.2739 27.5066 67.6107 77.0253 211.223 226.547
2 Afghanistan AFG 1951 324.777 374.956 7.65714 6.47173 9.87427 8.0444 14.9049 14.7495 21.0961 27.2708 67.1116 76.5053 209.885 225.159
3 Afghanistan AFG 1952 318.286 366.965 7.51281 6.3596 9.6892 7.90725 14.6317 14.4965 20.7428 26.8212 66.1187 75.5487 207.22 222.703
4 Afghanistan AFG 1953 311.888 358.685 7.37038 6.25279 9.50655 7.77702 14.3619 14.2566 20.3934 26.3985 65.1349 74.6933 204.573 220.633
5 Afghanistan AFG 1954 305.975 351.087 7.47033 6.32612 9.54872 7.80432 14.3075 14.1708 20.3094 26.2079 64.6866 74.327 202.837 219.442
6 Afghanistan AFG 1955 298.864 342.552 7.08519 6.0428 9.14193 7.52088 13.824 13.7848 19.7027 25.5661 63.2202 72.9975 199.518 216.517
7 Afghanistan AFG 1956 292.437 334.788 6.9579 5.95098 8.97388 7.40485 13.5696 13.5633 19.3775 25.173 62.3198 72.1939 197.145 214.542
8 Afghanistan AFG 1957 285.96 327.082 6.80497 5.82437 8.78425 7.25426 13.2964 13.2944 19.0277 24.7002 61.3636 71.1901 194.668 212.095
9 Afghanistan AFG 1958 279.403 319.298 6.66214 5.69684 8.60189 7.09851 13.0273 13.0086 18.6822 24.1954 60.4097 70.1002 192.166 209.401
10 Afghanistan AFG 1959 273.273 312.183 6.52603 5.58004 8.42824 6.9558 12.7715 12.7468 18.3544 23.7325 59.5094 69.0955 189.867 206.911
11 Afghanistan AFG 1960 267.463 305.598 6.40648 5.48074 8.27133 6.83256 12.5389 12.5175 18.0579 23.3241 58.6735 68.2023 187.792 204.59
12 Afghanistan AFG 1961 261.854 298.886 6.26721 5.3612 8.09831 6.68825 12.2866 12.256 17.7335 22.8633 57.8106 67.1957 185.652 202.185
13 Afghanistan AFG 1962 256.655 292.773 6.14919 5.26366 7.9478 6.56954 12.0652 12.0384 17.4491 22.4812 57.0294 66.3898 183.704 200.26
19911 Zimbabwe ZWE 2010 53.9416 60.8736 1.63101 1.90256 2.49942 2.61754 8.802 8.97857 20.8596 27.2927 45.8422 52.5112 86.3175 114.257
19912 Zimbabwe ZWE 2011 50.7671 57.5466 1.5059 1.7603 2.24074 2.40589 6.98757 7.8604 16.663 23.4714 41.1328 49.1328 85.6723 113.942
19913 Zimbabwe ZWE 2012 45.8417 52.3628 1.2744 1.53946 1.90764 2.12629 5.97021 6.73963 14.7873 20.558 37.6887 46.8993 85.0377 113.63
19914 Zimbabwe ZWE 2013 42.4171 48.8878 1.14827 1.36861 1.71382 1.9229 5.13833 5.92327 13.1951 18.2398 35.8164 45.3136 84.4419 113.357
19915 Zimbabwe ZWE 2014 40.2433 46.6497 1.06513 1.26043 1.58333 1.78416 4.57123 5.31936 12.052 16.3566 34.5043 43.8205 83.7835 113.008
19916 Zimbabwe ZWE 2015 39.3862 45.7603 1.03008 1.21829 1.51606 1.7263 4.23604 5.0488 11.3024 15.4633 33.6349 43.0445 83.1682 112.702
19917 Zimbabwe ZWE 2016 37.7949 44.0875 0.97629 1.14752 1.43611 1.64832 3.93881 4.80345 10.7236 14.872 32.8932 42.7217 82.5508 112.388
19918 Zimbabwe ZWE 2017 36.8661 43.1389 0.95685 1.12218 1.38986 1.61538 3.73174 4.70667 10.2912 14.6938 32.3443 42.7099 81.9914 112.102
19919 Zimbabwe ZWE 2018 35.4646 41.6297 0.89795 1.04302 1.32043 1.53221 3.51856 4.42719 9.86634 13.892 31.726 42.13 81.3326 111.776
19920 Zimbabwe ZWE 2019 35.3383 41.4167 0.93255 1.07613 1.32845 1.55651 3.48048 4.53653 9.78645 14.3989 31.6513 42.7631 80.8855 111.541
19921 Zimbabwe ZWE 2020 34.9539 40.9834 0.87637 1.02782 1.20826 1.39351 3.11532 4.14614 9.38663 15.0135 33.6533 48.0212 82.9557 120.98
19922 Zimbabwe ZWE 2021 34.9083 40.922 0.86883 1.02383 1.30698 1.58042 3.38878 4.70133 10.5541 17.1106 38.6799 56.6425 100.369 143.754
Code
female_data=@chain df begin
   @filter(Year==2021)
   @select(1,3:17)
   @select(startswith("female"))
   @summarize(female_age0=mean(female_age0),female_age10=mean(female_age10),female_age15=mean(female_age15),female_age25=mean(female_age25),    female_age45=mean(female_age45),female_age65=mean(female_age65),female_age80=mean(female_age80))
end
1×7 DataFrame
Row female_age0 female_age10 female_age15 female_age25 female_age45 female_age65 female_age80
Float64 Float64 Float64 Float64 Float64 Float64 Float64
1 16.8304 0.426706 0.564174 1.06755 3.32511 18.0247 77.9603
Code
male_data=@chain df begin
   @filter(Year==2021)
   @select(1,3:17)
   @select(startswith("male"))
   @summarize(male_age0=mean(male_age0),male_age10=mean(male_age10),male_age15=mean(male_age15),male_age25=mean(male_age25),male_age45=mean(male_age45),male_age65=mean(male_age65),male_age80=mean(male_age80))
end
1×7 DataFrame
Row male_age0 male_age10 male_age15 male_age25 male_age45 male_age65 male_age80
Float64 Float64 Float64 Float64 Float64 Float64 Float64
1 20.0176 0.504313 0.759778 1.84672 5.45103 29.892 109.894