14-day cumulative number of COVID-19 cases per 100 000¶
At the end of the page, we provide a detailed description of how the numbers are calculated.
Compute data¶
In [1]:
import pandas as pd
pd.set_option("display.max_rows", None)
from oscovida import get_incidence_rates_countries
Table for all countries¶
In [2]:
cases_incidence, deaths_incidence = get_incidence_rates_countries()
Downloaded data: last data point 1/25/23 from https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv Downloaded data: last data point 1/25/23 from https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv
/tank/oscovida/work/oscovida.github.io/oscovida.github.io/.venv/lib/python3.9/site-packages/oscovida/oscovida.py:597: FutureWarning: The default value of numeric_only in DataFrameGroupBy.sum is deprecated. In a future version, numeric_only will default to False. Either specify numeric_only or select only columns which should be valid for the function. cases = cases.groupby(cases.index).sum().astype(int) /tank/oscovida/work/oscovida.github.io/oscovida.github.io/.venv/lib/python3.9/site-packages/oscovida/oscovida.py:598: FutureWarning: The default value of numeric_only in DataFrameGroupBy.sum is deprecated. In a future version, numeric_only will default to False. Either specify numeric_only or select only columns which should be valid for the function. deaths = deaths.groupby(deaths.index).sum().astype(int) /tank/oscovida/work/oscovida.github.io/oscovida.github.io/.venv/lib/python3.9/site-packages/oscovida/oscovida.py:520: FutureWarning: The default value of numeric_only in DataFrameGroupBy.sum is deprecated. In a future version, numeric_only will default to False. Either specify numeric_only or select only columns which should be valid for the function. population
In [3]:
cases_incidence
Out[3]:
14-day-sum | population | 14-day-incidence-rate | |
---|---|---|---|
Country | |||
Afghanistan | 424 | 38928341 | 1.1 |
Albania | 129 | 2877800 | 4.5 |
Algeria | 92 | 43851043 | 0.2 |
Andorra | 39 | 77265 | 50.5 |
Angola | 89 | 32866268 | 0.3 |
Antarctica | 0 | 0 | NaN |
Antigua and Barbuda | 0 | 97928 | 0.0 |
Argentina | 28030 | 45195777 | 62.0 |
Armenia | 32 | 2963234 | 1.1 |
Australia | 61807 | 25459700 | 242.8 |
Austria | 28574 | 9006400 | 317.3 |
Azerbaijan | 725 | 10139175 | 7.2 |
Bahamas | 0 | 393248 | 0.0 |
Bahrain | 803 | 1701583 | 47.2 |
Bangladesh | 151 | 164689383 | 0.1 |
Barbados | 252 | 287371 | 87.7 |
Belarus | 0 | 9449321 | 0.0 |
Belgium | 6693 | 11492641 | 58.2 |
Belize | 213 | 397621 | 53.6 |
Benin | 7 | 12123198 | 0.1 |
Bhutan | 47 | 771612 | 6.1 |
Bolivia | 11054 | 11673029 | 94.7 |
Bosnia and Herzegovina | 168 | 3280815 | 5.1 |
Botswana | 657 | 2351625 | 27.9 |
Brazil | 189812 | 212559409 | 89.3 |
Brunei | 2574 | 437483 | 588.4 |
Bulgaria | 1323 | 6948445 | 19.0 |
Burkina Faso | 0 | 20903278 | 0.0 |
Burma | 84 | 54409794 | 0.2 |
Burundi | 49 | 11890781 | 0.4 |
Cabo Verde | 10 | 555988 | 1.8 |
Cambodia | 37 | 16718971 | 0.2 |
Cameroon | 0 | 26545864 | 0.0 |
Canada | 24280 | 38246108 | 63.5 |
Central African Republic | 10 | 4829764 | 0.2 |
Chad | 1 | 16425859 | 0.0 |
Chile | 34092 | 19116209 | 178.3 |
China | 64562 | 1411778724 | 4.6 |
Colombia | 5297 | 50882884 | 10.4 |
Comoros | 6 | 869595 | 0.7 |
Congo (Brazzaville) | 0 | 5518092 | 0.0 |
Congo (Kinshasa) | 300 | 89561404 | 0.3 |
Costa Rica | 10569 | 5094114 | 207.5 |
Cote d'Ivoire | 6 | 26378275 | 0.0 |
Croatia | 1301 | 4105268 | 31.7 |
Cuba | 168 | 11326616 | 1.5 |
Cyprus | 6020 | 1207361 | 498.6 |
Czechia | 3697 | 10708982 | 34.5 |
Denmark | 2845 | 5837213 | 48.7 |
Diamond Princess | 0 | 0 | NaN |
Djibouti | 0 | 988002 | 0.0 |
Dominica | 0 | 71991 | 0.0 |
Dominican Republic | 412 | 10847904 | 3.8 |
Ecuador | 10776 | 17643060 | 61.1 |
Egypt | 0 | 102334403 | 0.0 |
El Salvador | 0 | 6486201 | 0.0 |
Equatorial Guinea | 0 | 1402985 | 0.0 |
Eritrea | 0 | 3546427 | 0.0 |
Estonia | 688 | 1326539 | 51.9 |
Eswatini | 61 | 1160164 | 5.3 |
Ethiopia | 469 | 114963583 | 0.4 |
Fiji | 37 | 896444 | 4.1 |
Finland | 3432 | 5540718 | 61.9 |
France | 69578 | 65249843 | 106.6 |
Gabon | 0 | 2225728 | 0.0 |
Gambia | 0 | 2416664 | 0.0 |
Georgia | 4821 | 3989175 | 120.9 |
Germany | 133430 | 83155031 | 160.5 |
Ghana | 42 | 31072945 | 0.1 |
Greece | 0 | 10423056 | 0.0 |
Grenada | 0 | 112519 | 0.0 |
Guatemala | 10116 | 17915567 | 56.5 |
Guinea | 30 | 13132792 | 0.2 |
Guinea-Bissau | 0 | 1967998 | 0.0 |
Guyana | 340 | 786559 | 43.2 |
Haiti | 39 | 11402533 | 0.3 |
Holy See | 0 | 809 | 0.0 |
Honduras | 2289 | 9904608 | 23.1 |
Hungary | 1493 | 9660350 | 15.5 |
Iceland | 146 | 341250 | 42.8 |
India | 1755 | 1380004385 | 0.1 |
Indonesia | 3993 | 273523621 | 1.5 |
Iran | 1453 | 83992953 | 1.7 |
Iraq | 0 | 40222503 | 0.0 |
Ireland | 2478 | 4937796 | 50.2 |
Israel | 9399 | 8655541 | 108.6 |
Italy | 135948 | 60461828 | 224.8 |
Jamaica | 439 | 2961161 | 14.8 |
Japan | 1404322 | 126476458 | 1110.3 |
Jordan | 0 | 10203140 | 0.0 |
Kazakhstan | 7877 | 18776707 | 42.0 |
Kenya | 166 | 53771300 | 0.3 |
Kiribati | 70 | 117606 | 59.5 |
Korea, North | 0 | 25778815 | 0.0 |
Korea, South | 377609 | 51269183 | 736.5 |
Kosovo | 153 | 1810366 | 8.5 |
Kuwait | 111 | 4270563 | 2.6 |
Kyrgyzstan | 5 | 6524191 | 0.1 |
Laos | 36 | 7275556 | 0.5 |
Latvia | 393 | 1886202 | 20.8 |
Lebanon | 3153 | 6825442 | 46.2 |
Lesotho | 0 | 2142252 | 0.0 |
Liberia | 10 | 5057677 | 0.2 |
Libya | 5 | 6871287 | 0.1 |
Liechtenstein | 14 | 38137 | 36.7 |
Lithuania | 3324 | 2722291 | 122.1 |
Luxembourg | 675 | 625976 | 107.8 |
MS Zaandam | 0 | 0 | NaN |
Madagascar | 57 | 27691019 | 0.2 |
Malawi | 285 | 19129955 | 1.5 |
Malaysia | 3762 | 32365998 | 11.6 |
Maldives | 11 | 540542 | 2.0 |
Mali | 4 | 20250834 | 0.0 |
Malta | 223 | 441539 | 50.5 |
Marshall Islands | 0 | 58413 | 0.0 |
Mauritania | 229 | 4649660 | 4.9 |
Mauritius | 703 | 1271767 | 55.3 |
Mexico | 63790 | 127792286 | 49.9 |
Micronesia | 429 | 113815 | 376.9 |
Moldova | 857 | 4027690 | 21.3 |
Monaco | 37 | 39244 | 94.3 |
Mongolia | 62 | 3278292 | 1.9 |
Montenegro | 778 | 628062 | 123.9 |
Morocco | 218 | 36910558 | 0.6 |
Mozambique | 775 | 31255435 | 2.5 |
Namibia | 127 | 2540916 | 5.0 |
Nauru | 0 | 10834 | 0.0 |
Nepal | 48 | 29136808 | 0.2 |
Netherlands | 4195 | 17134873 | 24.5 |
New Zealand | 33216 | 4822233 | 688.8 |
Nicaragua | 34 | 6624554 | 0.5 |
Niger | 35 | 24206636 | 0.1 |
Nigeria | 0 | 206139587 | 0.0 |
North Macedonia | 333 | 2083380 | 16.0 |
Norway | 900 | 5421242 | 16.6 |
Oman | 0 | 5106622 | 0.0 |
Pakistan | 171 | 220892331 | 0.1 |
Palau | 10 | 18008 | 55.5 |
Panama | 1814 | 4314768 | 42.0 |
Papua New Guinea | 0 | 8947027 | 0.0 |
Paraguay | 7255 | 7132530 | 101.7 |
Peru | 5825 | 32971846 | 17.7 |
Philippines | 3459 | 109581085 | 3.2 |
Poland | 4472 | 37846605 | 11.8 |
Portugal | 4948 | 10196707 | 48.5 |
Qatar | 1107 | 2881060 | 38.4 |
Romania | 6456 | 19237682 | 33.6 |
Russia | 72414 | 145934460 | 49.6 |
Rwanda | 27 | 12952209 | 0.2 |
Saint Kitts and Nevis | 14 | 53192 | 26.3 |
Saint Lucia | 44 | 183629 | 24.0 |
Saint Vincent and the Grenadines | 18 | 110947 | 16.2 |
Samoa | 14 | 196130 | 7.1 |
San Marino | 113 | 33938 | 333.0 |
Sao Tome and Principe | 0 | 219161 | 0.0 |
Saudi Arabia | 432 | 34813867 | 1.2 |
Senegal | 0 | 16743930 | 0.0 |
Serbia | 9346 | 8737370 | 107.0 |
Seychelles | 0 | 98340 | 0.0 |
Sierra Leone | 0 | 7976985 | 0.0 |
Singapore | 4492 | 5850343 | 76.8 |
Slovakia | 1432 | 5434712 | 26.3 |
Slovenia | 4411 | 2078932 | 212.2 |
Solomon Islands | 0 | 652858 | 0.0 |
Somalia | 8 | 15893219 | 0.1 |
South Africa | 3913 | 59308690 | 6.6 |
South Sudan | 0 | 11193729 | 0.0 |
Spain | 29199 | 46754783 | 62.5 |
Sri Lanka | 36 | 21413250 | 0.2 |
Sudan | 27 | 43849269 | 0.1 |
Summer Olympics 2020 | 0 | 0 | NaN |
Suriname | 0 | 586634 | 0.0 |
Sweden | 7117 | 10099270 | 70.5 |
Switzerland | 1263 | 8654618 | 14.6 |
Syria | 27 | 17500657 | 0.2 |
Taiwan* | 261811 | 23816775 | 1099.3 |
Tajikistan | 0 | 9537642 | 0.0 |
Tanzania | 133 | 59734213 | 0.2 |
Thailand | 1596 | 69799978 | 2.3 |
Timor-Leste | 8 | 1318442 | 0.6 |
Togo | 3 | 8278737 | 0.0 |
Tonga | 82 | 105697 | 77.6 |
Trinidad and Tobago | 900 | 1399491 | 64.3 |
Tunisia | 2549 | 11818618 | 21.6 |
Turkey | 0 | 84339067 | 0.0 |
Tuvalu | 0 | 11792 | 0.0 |
US | 635574 | 329466283 | 192.9 |
Uganda | 49 | 45741000 | 0.1 |
Ukraine | 6317 | 43733759 | 14.4 |
United Arab Emirates | 1218 | 9890400 | 12.3 |
United Kingdom | 49851 | 67886004 | 73.4 |
Uruguay | 5771 | 3473727 | 166.1 |
Uzbekistan | 361 | 33469199 | 1.1 |
Vanuatu | 0 | 292680 | 0.0 |
Venezuela | 549 | 28435943 | 1.9 |
Vietnam | 402 | 97338583 | 0.4 |
West Bank and Gaza | 0 | 5101416 | 0.0 |
Winter Olympics 2022 | 0 | 0 | NaN |
Yemen | 0 | 29825968 | 0.0 |
Zambia | 3414 | 18383956 | 18.6 |
Zimbabwe | 1625 | 14862927 | 10.9 |
Table sorted by 14-day-incidence¶
In [4]:
cases_incidence.sort_values(by=['14-day-incidence-rate'], ascending=False)
Out[4]:
14-day-sum | population | 14-day-incidence-rate | |
---|---|---|---|
Country | |||
Japan | 1404322 | 126476458 | 1110.3 |
Taiwan* | 261811 | 23816775 | 1099.3 |
Korea, South | 377609 | 51269183 | 736.5 |
New Zealand | 33216 | 4822233 | 688.8 |
Brunei | 2574 | 437483 | 588.4 |
Cyprus | 6020 | 1207361 | 498.6 |
Micronesia | 429 | 113815 | 376.9 |
San Marino | 113 | 33938 | 333.0 |
Austria | 28574 | 9006400 | 317.3 |
Australia | 61807 | 25459700 | 242.8 |
Italy | 135948 | 60461828 | 224.8 |
Slovenia | 4411 | 2078932 | 212.2 |
Costa Rica | 10569 | 5094114 | 207.5 |
US | 635574 | 329466283 | 192.9 |
Chile | 34092 | 19116209 | 178.3 |
Uruguay | 5771 | 3473727 | 166.1 |
Germany | 133430 | 83155031 | 160.5 |
Montenegro | 778 | 628062 | 123.9 |
Lithuania | 3324 | 2722291 | 122.1 |
Georgia | 4821 | 3989175 | 120.9 |
Israel | 9399 | 8655541 | 108.6 |
Luxembourg | 675 | 625976 | 107.8 |
Serbia | 9346 | 8737370 | 107.0 |
France | 69578 | 65249843 | 106.6 |
Paraguay | 7255 | 7132530 | 101.7 |
Bolivia | 11054 | 11673029 | 94.7 |
Monaco | 37 | 39244 | 94.3 |
Brazil | 189812 | 212559409 | 89.3 |
Barbados | 252 | 287371 | 87.7 |
Tonga | 82 | 105697 | 77.6 |
Singapore | 4492 | 5850343 | 76.8 |
United Kingdom | 49851 | 67886004 | 73.4 |
Sweden | 7117 | 10099270 | 70.5 |
Trinidad and Tobago | 900 | 1399491 | 64.3 |
Canada | 24280 | 38246108 | 63.5 |
Spain | 29199 | 46754783 | 62.5 |
Argentina | 28030 | 45195777 | 62.0 |
Finland | 3432 | 5540718 | 61.9 |
Ecuador | 10776 | 17643060 | 61.1 |
Kiribati | 70 | 117606 | 59.5 |
Belgium | 6693 | 11492641 | 58.2 |
Guatemala | 10116 | 17915567 | 56.5 |
Palau | 10 | 18008 | 55.5 |
Mauritius | 703 | 1271767 | 55.3 |
Belize | 213 | 397621 | 53.6 |
Estonia | 688 | 1326539 | 51.9 |
Andorra | 39 | 77265 | 50.5 |
Malta | 223 | 441539 | 50.5 |
Ireland | 2478 | 4937796 | 50.2 |
Mexico | 63790 | 127792286 | 49.9 |
Russia | 72414 | 145934460 | 49.6 |
Denmark | 2845 | 5837213 | 48.7 |
Portugal | 4948 | 10196707 | 48.5 |
Bahrain | 803 | 1701583 | 47.2 |
Lebanon | 3153 | 6825442 | 46.2 |
Guyana | 340 | 786559 | 43.2 |
Iceland | 146 | 341250 | 42.8 |
Panama | 1814 | 4314768 | 42.0 |
Kazakhstan | 7877 | 18776707 | 42.0 |
Qatar | 1107 | 2881060 | 38.4 |
Liechtenstein | 14 | 38137 | 36.7 |
Czechia | 3697 | 10708982 | 34.5 |
Romania | 6456 | 19237682 | 33.6 |
Croatia | 1301 | 4105268 | 31.7 |
Botswana | 657 | 2351625 | 27.9 |
Saint Kitts and Nevis | 14 | 53192 | 26.3 |
Slovakia | 1432 | 5434712 | 26.3 |
Netherlands | 4195 | 17134873 | 24.5 |
Saint Lucia | 44 | 183629 | 24.0 |
Honduras | 2289 | 9904608 | 23.1 |
Tunisia | 2549 | 11818618 | 21.6 |
Moldova | 857 | 4027690 | 21.3 |
Latvia | 393 | 1886202 | 20.8 |
Bulgaria | 1323 | 6948445 | 19.0 |
Zambia | 3414 | 18383956 | 18.6 |
Peru | 5825 | 32971846 | 17.7 |
Norway | 900 | 5421242 | 16.6 |
Saint Vincent and the Grenadines | 18 | 110947 | 16.2 |
North Macedonia | 333 | 2083380 | 16.0 |
Hungary | 1493 | 9660350 | 15.5 |
Jamaica | 439 | 2961161 | 14.8 |
Switzerland | 1263 | 8654618 | 14.6 |
Ukraine | 6317 | 43733759 | 14.4 |
United Arab Emirates | 1218 | 9890400 | 12.3 |
Poland | 4472 | 37846605 | 11.8 |
Malaysia | 3762 | 32365998 | 11.6 |
Zimbabwe | 1625 | 14862927 | 10.9 |
Colombia | 5297 | 50882884 | 10.4 |
Kosovo | 153 | 1810366 | 8.5 |
Azerbaijan | 725 | 10139175 | 7.2 |
Samoa | 14 | 196130 | 7.1 |
South Africa | 3913 | 59308690 | 6.6 |
Bhutan | 47 | 771612 | 6.1 |
Eswatini | 61 | 1160164 | 5.3 |
Bosnia and Herzegovina | 168 | 3280815 | 5.1 |
Namibia | 127 | 2540916 | 5.0 |
Mauritania | 229 | 4649660 | 4.9 |
China | 64562 | 1411778724 | 4.6 |
Albania | 129 | 2877800 | 4.5 |
Fiji | 37 | 896444 | 4.1 |
Dominican Republic | 412 | 10847904 | 3.8 |
Philippines | 3459 | 109581085 | 3.2 |
Kuwait | 111 | 4270563 | 2.6 |
Mozambique | 775 | 31255435 | 2.5 |
Thailand | 1596 | 69799978 | 2.3 |
Maldives | 11 | 540542 | 2.0 |
Venezuela | 549 | 28435943 | 1.9 |
Mongolia | 62 | 3278292 | 1.9 |
Cabo Verde | 10 | 555988 | 1.8 |
Iran | 1453 | 83992953 | 1.7 |
Cuba | 168 | 11326616 | 1.5 |
Malawi | 285 | 19129955 | 1.5 |
Indonesia | 3993 | 273523621 | 1.5 |
Saudi Arabia | 432 | 34813867 | 1.2 |
Armenia | 32 | 2963234 | 1.1 |
Afghanistan | 424 | 38928341 | 1.1 |
Uzbekistan | 361 | 33469199 | 1.1 |
Comoros | 6 | 869595 | 0.7 |
Timor-Leste | 8 | 1318442 | 0.6 |
Morocco | 218 | 36910558 | 0.6 |
Laos | 36 | 7275556 | 0.5 |
Nicaragua | 34 | 6624554 | 0.5 |
Vietnam | 402 | 97338583 | 0.4 |
Ethiopia | 469 | 114963583 | 0.4 |
Burundi | 49 | 11890781 | 0.4 |
Congo (Kinshasa) | 300 | 89561404 | 0.3 |
Haiti | 39 | 11402533 | 0.3 |
Kenya | 166 | 53771300 | 0.3 |
Angola | 89 | 32866268 | 0.3 |
Cambodia | 37 | 16718971 | 0.2 |
Algeria | 92 | 43851043 | 0.2 |
Central African Republic | 10 | 4829764 | 0.2 |
Liberia | 10 | 5057677 | 0.2 |
Rwanda | 27 | 12952209 | 0.2 |
Tanzania | 133 | 59734213 | 0.2 |
Syria | 27 | 17500657 | 0.2 |
Sri Lanka | 36 | 21413250 | 0.2 |
Guinea | 30 | 13132792 | 0.2 |
Madagascar | 57 | 27691019 | 0.2 |
Burma | 84 | 54409794 | 0.2 |
Nepal | 48 | 29136808 | 0.2 |
Libya | 5 | 6871287 | 0.1 |
Uganda | 49 | 45741000 | 0.1 |
Niger | 35 | 24206636 | 0.1 |
India | 1755 | 1380004385 | 0.1 |
Benin | 7 | 12123198 | 0.1 |
Kyrgyzstan | 5 | 6524191 | 0.1 |
Sudan | 27 | 43849269 | 0.1 |
Bangladesh | 151 | 164689383 | 0.1 |
Pakistan | 171 | 220892331 | 0.1 |
Somalia | 8 | 15893219 | 0.1 |
Ghana | 42 | 31072945 | 0.1 |
Suriname | 0 | 586634 | 0.0 |
Vanuatu | 0 | 292680 | 0.0 |
Togo | 3 | 8278737 | 0.0 |
Bahamas | 0 | 393248 | 0.0 |
Burkina Faso | 0 | 20903278 | 0.0 |
Yemen | 0 | 29825968 | 0.0 |
Tajikistan | 0 | 9537642 | 0.0 |
Tuvalu | 0 | 11792 | 0.0 |
Turkey | 0 | 84339067 | 0.0 |
Belarus | 0 | 9449321 | 0.0 |
West Bank and Gaza | 0 | 5101416 | 0.0 |
Antigua and Barbuda | 0 | 97928 | 0.0 |
Jordan | 0 | 10203140 | 0.0 |
South Sudan | 0 | 11193729 | 0.0 |
Equatorial Guinea | 0 | 1402985 | 0.0 |
Korea, North | 0 | 25778815 | 0.0 |
Lesotho | 0 | 2142252 | 0.0 |
Holy See | 0 | 809 | 0.0 |
Guinea-Bissau | 0 | 1967998 | 0.0 |
Mali | 4 | 20250834 | 0.0 |
Grenada | 0 | 112519 | 0.0 |
Marshall Islands | 0 | 58413 | 0.0 |
Greece | 0 | 10423056 | 0.0 |
Gambia | 0 | 2416664 | 0.0 |
Gabon | 0 | 2225728 | 0.0 |
Nauru | 0 | 10834 | 0.0 |
Eritrea | 0 | 3546427 | 0.0 |
Nigeria | 0 | 206139587 | 0.0 |
El Salvador | 0 | 6486201 | 0.0 |
Solomon Islands | 0 | 652858 | 0.0 |
Oman | 0 | 5106622 | 0.0 |
Egypt | 0 | 102334403 | 0.0 |
Papua New Guinea | 0 | 8947027 | 0.0 |
Dominica | 0 | 71991 | 0.0 |
Djibouti | 0 | 988002 | 0.0 |
Iraq | 0 | 40222503 | 0.0 |
Congo (Brazzaville) | 0 | 5518092 | 0.0 |
Chad | 1 | 16425859 | 0.0 |
Sao Tome and Principe | 0 | 219161 | 0.0 |
Senegal | 0 | 16743930 | 0.0 |
Cameroon | 0 | 26545864 | 0.0 |
Seychelles | 0 | 98340 | 0.0 |
Sierra Leone | 0 | 7976985 | 0.0 |
Cote d'Ivoire | 6 | 26378275 | 0.0 |
Antarctica | 0 | 0 | NaN |
Diamond Princess | 0 | 0 | NaN |
MS Zaandam | 0 | 0 | NaN |
Summer Olympics 2020 | 0 | 0 | NaN |
Winter Olympics 2022 | 0 | 0 | NaN |
Tutorial: Detailed calculation for one country¶
In [5]:
from oscovida import fetch_cases, get_population
import datetime
In [6]:
period = 14 # Days we compute the incidence rate over
In [7]:
cases = fetch_cases() # Get a DataFrame where each row is the country, and columns cumulative case numbers
cases = cases.groupby(cases.index).sum() # Merge the rows for different regions as we want the numbers for an entire country
/tmp/ipykernel_3403315/1570404713.py:2: FutureWarning: The default value of numeric_only in DataFrameGroupBy.sum is deprecated. In a future version, numeric_only will default to False. Either specify numeric_only or select only columns which should be valid for the function. cases = cases.groupby(cases.index).sum() # Merge the rows for different regions as we want the numbers for an entire country
In [8]:
cases_germany = cases.loc['Germany'][2:] # First 2 entries are lat/lon so we only take the subsequent ones
cases_germany.tail()
Out[8]:
1/21/23 37668384.0 1/22/23 37668384.0 1/23/23 37684456.0 1/24/23 37701193.0 1/25/23 37715000.0 Name: Germany, dtype: float64
In [9]:
yesterday = datetime.datetime.now() - datetime.timedelta(days=1)
x_days_ago = yesterday - datetime.timedelta(days=period)
In [10]:
period_mask = (
(yesterday > pd.to_datetime(cases_germany.index)) &
(pd.to_datetime(cases_germany.index) > x_days_ago)
) # Mask for dates between today and x days ago
In [11]:
cases_in_period_per_day_germany = cases_germany[period_mask].diff() # Apply the period mask and get the diff to get the daily new cases
cases_in_period_per_day_germany
Out[11]:
1/12/23 NaN 1/13/23 10609.0 1/14/23 0.0 1/15/23 0.0 1/16/23 17222.0 1/17/23 15450.0 1/18/23 12001.0 1/19/23 9710.0 1/20/23 8866.0 1/21/23 0.0 1/22/23 0.0 1/23/23 16072.0 1/24/23 16737.0 1/25/23 13807.0 Name: Germany, dtype: float64
In [12]:
cases_in_period_per_day_germany.plot() # We can easily look at new cases per day
Out[12]:
<AxesSubplot: >
In [13]:
population = get_population().population
In [14]:
population_germany = population.loc['Germany'] # Get the population of Germany
population_germany
Out[14]:
83155031.0
In [15]:
incidence_rate_germany = cases_in_period_per_day_germany.sum() / population_germany * 100_000
incidence_rate_germany # By convention this is total cases over period / population * 100_000
Out[15]:
144.87878670864785
In [ ]: