|
15 | 15 | "source": [ |
16 | 16 | "Let's visualize the realtionship or lack thereof of two datasets.\n", |
17 | 17 | "\n", |
18 | | - "We are going to see if there is a relationship between the average supply of protein of animal origin and the number of people undernourished in South Africa" |
| 18 | + "We will be looking at two FAO dataset. One on the number of undernourished pople in south Africa; the other on the average supply of protein of animal origin. \n", |
| 19 | + "\n", |
| 20 | + "We will be trying to see the trends of each, wether they are similar, what could be expected, etc.." |
19 | 21 | ] |
20 | 22 | }, |
21 | 23 | { |
|
35 | 37 | "metadata": {}, |
36 | 38 | "source": [ |
37 | 39 | "Let's first take a look at each dataset and reshape them. \n", |
38 | | - "1) number of people undernourished\n", |
39 | | - "2) average supply of protein of animal origin" |
| 40 | + "1) Number of people undernourished\n", |
| 41 | + "2) Average supply of protein of animal origin" |
40 | 42 | ] |
41 | 43 | }, |
42 | 44 | { |
|
272 | 274 | "undernourished.head()" |
273 | 275 | ] |
274 | 276 | }, |
| 277 | + { |
| 278 | + "cell_type": "markdown", |
| 279 | + "id": "ac76c5a8", |
| 280 | + "metadata": {}, |
| 281 | + "source": [ |
| 282 | + "Lots of columns, too much noise. Let's see which column do we need." |
| 283 | + ] |
| 284 | + }, |
275 | 285 | { |
276 | 286 | "cell_type": "code", |
277 | | - "execution_count": 13, |
| 287 | + "execution_count": 4, |
278 | 288 | "id": "9957812a", |
279 | 289 | "metadata": {}, |
280 | 290 | "outputs": [ |
|
295 | 305 | " dtype='object')" |
296 | 306 | ] |
297 | 307 | }, |
298 | | - "execution_count": 13, |
| 308 | + "execution_count": 4, |
299 | 309 | "metadata": {}, |
300 | 310 | "output_type": "execute_result" |
301 | 311 | } |
|
304 | 314 | "undernourished.columns" |
305 | 315 | ] |
306 | 316 | }, |
| 317 | + { |
| 318 | + "cell_type": "markdown", |
| 319 | + "id": "17eb2b01", |
| 320 | + "metadata": {}, |
| 321 | + "source": [ |
| 322 | + "only those [\"REF_AREA\", \"REF_AREA_LABEL\",\"INDICATOR_LABEL\", \"TIME_PERIOD\", \"OBS_VALUE\"] will suffice. Let's cut the rest out" |
| 323 | + ] |
| 324 | + }, |
307 | 325 | { |
308 | 326 | "cell_type": "code", |
309 | | - "execution_count": 12, |
| 327 | + "execution_count": 5, |
310 | 328 | "id": "b5cd5c4a", |
311 | 329 | "metadata": {}, |
312 | 330 | "outputs": [ |
|
462 | 480 | "[3464 rows x 5 columns]" |
463 | 481 | ] |
464 | 482 | }, |
465 | | - "execution_count": 12, |
| 483 | + "execution_count": 5, |
466 | 484 | "metadata": {}, |
467 | 485 | "output_type": "execute_result" |
468 | 486 | } |
|
475 | 493 | "undernourished_by_country_year" |
476 | 494 | ] |
477 | 495 | }, |
| 496 | + { |
| 497 | + "cell_type": "markdown", |
| 498 | + "id": "1d6bb085", |
| 499 | + "metadata": {}, |
| 500 | + "source": [ |
| 501 | + "Now let's only keep the country we are interested in: South Africa" |
| 502 | + ] |
| 503 | + }, |
478 | 504 | { |
479 | 505 | "cell_type": "code", |
480 | | - "execution_count": 17, |
| 506 | + "execution_count": 6, |
481 | 507 | "id": "3f4d5f72", |
482 | 508 | "metadata": {}, |
483 | 509 | "outputs": [ |
|
810 | 836 | "2853 Number of people undernourished (3-year average) 2022 4600.0 " |
811 | 837 | ] |
812 | 838 | }, |
813 | | - "execution_count": 17, |
| 839 | + "execution_count": 6, |
814 | 840 | "metadata": {}, |
815 | 841 | "output_type": "execute_result" |
816 | 842 | } |
|
820 | 846 | "undernourished_south_africa" |
821 | 847 | ] |
822 | 848 | }, |
| 849 | + { |
| 850 | + "cell_type": "markdown", |
| 851 | + "id": "695dabda", |
| 852 | + "metadata": {}, |
| 853 | + "source": [ |
| 854 | + "let's take a look at the evolution of undernourished people in South Africa" |
| 855 | + ] |
| 856 | + }, |
823 | 857 | { |
824 | 858 | "cell_type": "code", |
825 | | - "execution_count": 18, |
| 859 | + "execution_count": 7, |
826 | 860 | "id": "012fa25d", |
827 | 861 | "metadata": {}, |
828 | 862 | "outputs": [ |
|
1681 | 1715 | "fig.show()" |
1682 | 1716 | ] |
1683 | 1717 | }, |
| 1718 | + { |
| 1719 | + "cell_type": "markdown", |
| 1720 | + "id": "3911faf0", |
| 1721 | + "metadata": {}, |
| 1722 | + "source": [ |
| 1723 | + "Let's repeapt the same steps for the other dataset: the average supply of protein of animal origin" |
| 1724 | + ] |
| 1725 | + }, |
1684 | 1726 | { |
1685 | 1727 | "cell_type": "code", |
1686 | | - "execution_count": 14, |
| 1728 | + "execution_count": 8, |
1687 | 1729 | "id": "118fb70a", |
1688 | 1730 | "metadata": {}, |
1689 | 1731 | "outputs": [ |
|
1903 | 1945 | "[5 rows x 38 columns]" |
1904 | 1946 | ] |
1905 | 1947 | }, |
1906 | | - "execution_count": 14, |
| 1948 | + "execution_count": 8, |
1907 | 1949 | "metadata": {}, |
1908 | 1950 | "output_type": "execute_result" |
1909 | 1951 | } |
|
1916 | 1958 | }, |
1917 | 1959 | { |
1918 | 1960 | "cell_type": "code", |
1919 | | - "execution_count": 15, |
| 1961 | + "execution_count": 9, |
1920 | 1962 | "id": "38c49a5a", |
1921 | 1963 | "metadata": {}, |
1922 | 1964 | "outputs": [ |
|
1936 | 1978 | " dtype='object')" |
1937 | 1979 | ] |
1938 | 1980 | }, |
1939 | | - "execution_count": 15, |
| 1981 | + "execution_count": 9, |
1940 | 1982 | "metadata": {}, |
1941 | 1983 | "output_type": "execute_result" |
1942 | 1984 | } |
|
1947 | 1989 | }, |
1948 | 1990 | { |
1949 | 1991 | "cell_type": "code", |
1950 | | - "execution_count": 16, |
| 1992 | + "execution_count": 10, |
1951 | 1993 | "id": "da606212", |
1952 | 1994 | "metadata": {}, |
1953 | 1995 | "outputs": [ |
|
2116 | 2158 | "[3709 rows x 5 columns]" |
2117 | 2159 | ] |
2118 | 2160 | }, |
2119 | | - "execution_count": 16, |
| 2161 | + "execution_count": 10, |
2120 | 2162 | "metadata": {}, |
2121 | 2163 | "output_type": "execute_result" |
2122 | 2164 | } |
|
2130 | 2172 | }, |
2131 | 2173 | { |
2132 | 2174 | "cell_type": "code", |
2133 | | - "execution_count": 19, |
| 2175 | + "execution_count": 11, |
2134 | 2176 | "id": "6298d1c9", |
2135 | 2177 | "metadata": {}, |
2136 | 2178 | "outputs": [ |
|
2406 | 2448 | "3114 40.7 " |
2407 | 2449 | ] |
2408 | 2450 | }, |
2409 | | - "execution_count": 19, |
| 2451 | + "execution_count": 11, |
2410 | 2452 | "metadata": {}, |
2411 | 2453 | "output_type": "execute_result" |
2412 | 2454 | } |
|
2418 | 2460 | }, |
2419 | 2461 | { |
2420 | 2462 | "cell_type": "code", |
2421 | | - "execution_count": null, |
| 2463 | + "execution_count": 12, |
2422 | 2464 | "id": "d5d912f0", |
2423 | 2465 | "metadata": {}, |
2424 | 2466 | "outputs": [ |
|
3282 | 3324 | "id": "e5ebb993", |
3283 | 3325 | "metadata": {}, |
3284 | 3326 | "source": [ |
3285 | | - "Let us now plot the two together" |
| 3327 | + "Let us now plot the two reworked dataset together" |
3286 | 3328 | ] |
3287 | 3329 | }, |
3288 | 3330 | { |
3289 | 3331 | "cell_type": "code", |
3290 | | - "execution_count": 22, |
| 3332 | + "execution_count": null, |
3291 | 3333 | "id": "4adb612b", |
3292 | 3334 | "metadata": {}, |
3293 | 3335 | "outputs": [ |
|
4150 | 4192 | "\n", |
4151 | 4193 | "fig = make_subplots(specs=[[{\"secondary_y\": True}]])\n", |
4152 | 4194 | "\n", |
4153 | | - "# Add traces\n", |
4154 | 4195 | "fig.add_trace(\n", |
4155 | 4196 | " go.Scatter(\n", |
4156 | 4197 | " x=undernourished_south_africa[\"TIME_PERIOD\"],\n", |
|
4169 | 4210 | " secondary_y=True,\n", |
4170 | 4211 | ")\n", |
4171 | 4212 | "\n", |
4172 | | - "# Add figure title\n", |
4173 | 4213 | "fig.update_layout(title_text=f\"Number of Undernourished People vs. Average Supply of Protein of Animal Origin, {country_name}\")\n", |
4174 | | - "\n", |
4175 | | - "# Set x-axis title\n", |
4176 | 4214 | "fig.update_xaxes(title_text=\"Year\")\n", |
4177 | | - "\n", |
4178 | | - "# Set y-axes titles\n", |
4179 | 4215 | "fig.update_yaxes(title_text=\"Number of Undernourished People\", secondary_y=False)\n", |
4180 | 4216 | "fig.update_yaxes(title_text=\"Average Supply of Animal Protein (g/capita/day)\", secondary_y=True)\n", |
4181 | 4217 | "\n", |
|
4187 | 4223 | "id": "90c1cf45", |
4188 | 4224 | "metadata": {}, |
4189 | 4225 | "source": [ |
4190 | | - "One would have expected that the trend in increase in average supply of animal protein in South Africa could have helped decrease the number of people undernourished. Surprisingly, both have increase in the direction." |
| 4226 | + "One could have expected that the increase trend in average supply of animal protein in South Africa could have helped decrease the number of people undernourished. Surprisingly, both have increased in the same direction.\n", |
| 4227 | + "\n", |
| 4228 | + "The two line shows a similar slope and even share a dip at the same moment in time. This might be an indicator that there is a correlation between the two observations or that both are affected by a common event but in any case we obviously cannot draw any causal conclusions as we missed a lot of control variables but there is a visiual similitude." |
4191 | 4229 | ] |
4192 | 4230 | } |
4193 | 4231 | ], |
|
0 commit comments