新型コロナ(COVID-19)の感染者・死者・検査・陽性率・ワクチン接種数の推移

[Data on COVID-19 (coronavirus) by Our World in Data](https://github.com/owid/covid-19-data/tree/master/public/data) で毎日更新されているデータがあるので、次のようにして新型コロナ(COVID-19)の感染者・死者・検査・ワクチン接種数の推移を見ることができます。


```python
import requests
import pandas as pd
import matplotlib.pyplot as plt
plt.style.use('ggplot') 

url = "https://github.com/owid/covid-19-data/blob/master/public/data/owid-covid-data.csv?raw=true"
df = pd.read_csv(url)
```


```python
df
```





<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>iso_code</th>
      <th>continent</th>
      <th>location</th>
      <th>date</th>
      <th>total_cases</th>
      <th>new_cases</th>
      <th>new_cases_smoothed</th>
      <th>total_deaths</th>
      <th>new_deaths</th>
      <th>new_deaths_smoothed</th>
      <th>total_cases_per_million</th>
      <th>new_cases_per_million</th>
      <th>new_cases_smoothed_per_million</th>
      <th>total_deaths_per_million</th>
      <th>new_deaths_per_million</th>
      <th>new_deaths_smoothed_per_million</th>
      <th>reproduction_rate</th>
      <th>icu_patients</th>
      <th>icu_patients_per_million</th>
      <th>hosp_patients</th>
      <th>hosp_patients_per_million</th>
      <th>weekly_icu_admissions</th>
      <th>weekly_icu_admissions_per_million</th>
      <th>weekly_hosp_admissions</th>
      <th>weekly_hosp_admissions_per_million</th>
      <th>new_tests</th>
      <th>total_tests</th>
      <th>total_tests_per_thousand</th>
      <th>new_tests_per_thousand</th>
      <th>new_tests_smoothed</th>
      <th>new_tests_smoothed_per_thousand</th>
      <th>positive_rate</th>
      <th>tests_per_case</th>
      <th>tests_units</th>
      <th>total_vaccinations</th>
      <th>people_vaccinated</th>
      <th>people_fully_vaccinated</th>
      <th>new_vaccinations</th>
      <th>new_vaccinations_smoothed</th>
      <th>total_vaccinations_per_hundred</th>
      <th>people_vaccinated_per_hundred</th>
      <th>people_fully_vaccinated_per_hundred</th>
      <th>new_vaccinations_smoothed_per_million</th>
      <th>stringency_index</th>
      <th>population</th>
      <th>population_density</th>
      <th>median_age</th>
      <th>aged_65_older</th>
      <th>aged_70_older</th>
      <th>gdp_per_capita</th>
      <th>extreme_poverty</th>
      <th>cardiovasc_death_rate</th>
      <th>diabetes_prevalence</th>
      <th>female_smokers</th>
      <th>male_smokers</th>
      <th>handwashing_facilities</th>
      <th>hospital_beds_per_thousand</th>
      <th>life_expectancy</th>
      <th>human_development_index</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>AFG</td>
      <td>Asia</td>
      <td>Afghanistan</td>
      <td>2020-02-24</td>
      <td>1.0</td>
      <td>1.0</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>0.026</td>
      <td>0.026</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>8.33</td>
      <td>38928341.0</td>
      <td>54.422</td>
      <td>18.6</td>
      <td>2.581</td>
      <td>1.337</td>
      <td>1803.987</td>
      <td>NaN</td>
      <td>597.029</td>
      <td>9.59</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>37.746</td>
      <td>0.5</td>
      <td>64.83</td>
      <td>0.511</td>
    </tr>
    <tr>
      <th>1</th>
      <td>AFG</td>
      <td>Asia</td>
      <td>Afghanistan</td>
      <td>2020-02-25</td>
      <td>1.0</td>
      <td>0.0</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>0.026</td>
      <td>0.000</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>8.33</td>
      <td>38928341.0</td>
      <td>54.422</td>
      <td>18.6</td>
      <td>2.581</td>
      <td>1.337</td>
      <td>1803.987</td>
      <td>NaN</td>
      <td>597.029</td>
      <td>9.59</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>37.746</td>
      <td>0.5</td>
      <td>64.83</td>
      <td>0.511</td>
    </tr>
    <tr>
      <th>2</th>
      <td>AFG</td>
      <td>Asia</td>
      <td>Afghanistan</td>
      <td>2020-02-26</td>
      <td>1.0</td>
      <td>0.0</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>0.026</td>
      <td>0.000</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>8.33</td>
      <td>38928341.0</td>
      <td>54.422</td>
      <td>18.6</td>
      <td>2.581</td>
      <td>1.337</td>
      <td>1803.987</td>
      <td>NaN</td>
      <td>597.029</td>
      <td>9.59</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>37.746</td>
      <td>0.5</td>
      <td>64.83</td>
      <td>0.511</td>
    </tr>
    <tr>
      <th>3</th>
      <td>AFG</td>
      <td>Asia</td>
      <td>Afghanistan</td>
      <td>2020-02-27</td>
      <td>1.0</td>
      <td>0.0</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>0.026</td>
      <td>0.000</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>8.33</td>
      <td>38928341.0</td>
      <td>54.422</td>
      <td>18.6</td>
      <td>2.581</td>
      <td>1.337</td>
      <td>1803.987</td>
      <td>NaN</td>
      <td>597.029</td>
      <td>9.59</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>37.746</td>
      <td>0.5</td>
      <td>64.83</td>
      <td>0.511</td>
    </tr>
    <tr>
      <th>4</th>
      <td>AFG</td>
      <td>Asia</td>
      <td>Afghanistan</td>
      <td>2020-02-28</td>
      <td>1.0</td>
      <td>0.0</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>0.026</td>
      <td>0.000</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>8.33</td>
      <td>38928341.0</td>
      <td>54.422</td>
      <td>18.6</td>
      <td>2.581</td>
      <td>1.337</td>
      <td>1803.987</td>
      <td>NaN</td>
      <td>597.029</td>
      <td>9.59</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>37.746</td>
      <td>0.5</td>
      <td>64.83</td>
      <td>0.511</td>
    </tr>
    <tr>
      <th>...</th>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
      <td>...</td>
    </tr>
    <tr>
      <th>92126</th>
      <td>ZWE</td>
      <td>Africa</td>
      <td>Zimbabwe</td>
      <td>2021-05-25</td>
      <td>38706.0</td>
      <td>10.0</td>
      <td>15.857</td>
      <td>1587.0</td>
      <td>1.0</td>
      <td>0.571</td>
      <td>2604.198</td>
      <td>0.673</td>
      <td>1.067</td>
      <td>106.776</td>
      <td>0.067</td>
      <td>0.038</td>
      <td>1.32</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>1416.0</td>
      <td>540768.0</td>
      <td>36.384</td>
      <td>0.095</td>
      <td>1937.0</td>
      <td>0.130</td>
      <td>0.008</td>
      <td>122.2</td>
      <td>tests performed</td>
      <td>927990.0</td>
      <td>639553.0</td>
      <td>288437.0</td>
      <td>13069.0</td>
      <td>13719.0</td>
      <td>6.24</td>
      <td>4.30</td>
      <td>1.94</td>
      <td>923.0</td>
      <td>NaN</td>
      <td>14862927.0</td>
      <td>42.729</td>
      <td>19.6</td>
      <td>2.822</td>
      <td>1.882</td>
      <td>1899.775</td>
      <td>21.4</td>
      <td>307.846</td>
      <td>1.82</td>
      <td>1.6</td>
      <td>30.7</td>
      <td>36.791</td>
      <td>1.7</td>
      <td>61.49</td>
      <td>0.571</td>
    </tr>
    <tr>
      <th>92127</th>
      <td>ZWE</td>
      <td>Africa</td>
      <td>Zimbabwe</td>
      <td>2021-05-26</td>
      <td>38819.0</td>
      <td>113.0</td>
      <td>29.571</td>
      <td>1589.0</td>
      <td>2.0</td>
      <td>0.857</td>
      <td>2611.800</td>
      <td>7.603</td>
      <td>1.990</td>
      <td>106.910</td>
      <td>0.135</td>
      <td>0.058</td>
      <td>1.38</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>1629.0</td>
      <td>542397.0</td>
      <td>36.493</td>
      <td>0.110</td>
      <td>1725.0</td>
      <td>0.116</td>
      <td>0.017</td>
      <td>58.3</td>
      <td>tests performed</td>
      <td>937040.0</td>
      <td>643531.0</td>
      <td>293509.0</td>
      <td>9050.0</td>
      <td>13194.0</td>
      <td>6.30</td>
      <td>4.33</td>
      <td>1.97</td>
      <td>888.0</td>
      <td>NaN</td>
      <td>14862927.0</td>
      <td>42.729</td>
      <td>19.6</td>
      <td>2.822</td>
      <td>1.882</td>
      <td>1899.775</td>
      <td>21.4</td>
      <td>307.846</td>
      <td>1.82</td>
      <td>1.6</td>
      <td>30.7</td>
      <td>36.791</td>
      <td>1.7</td>
      <td>61.49</td>
      <td>0.571</td>
    </tr>
    <tr>
      <th>92128</th>
      <td>ZWE</td>
      <td>Africa</td>
      <td>Zimbabwe</td>
      <td>2021-05-27</td>
      <td>38854.0</td>
      <td>35.0</td>
      <td>31.286</td>
      <td>1592.0</td>
      <td>3.0</td>
      <td>1.000</td>
      <td>2614.155</td>
      <td>2.355</td>
      <td>2.105</td>
      <td>107.112</td>
      <td>0.202</td>
      <td>0.067</td>
      <td>1.38</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>953389.0</td>
      <td>648121.0</td>
      <td>305268.0</td>
      <td>16349.0</td>
      <td>12285.0</td>
      <td>6.41</td>
      <td>4.36</td>
      <td>2.05</td>
      <td>827.0</td>
      <td>NaN</td>
      <td>14862927.0</td>
      <td>42.729</td>
      <td>19.6</td>
      <td>2.822</td>
      <td>1.882</td>
      <td>1899.775</td>
      <td>21.4</td>
      <td>307.846</td>
      <td>1.82</td>
      <td>1.6</td>
      <td>30.7</td>
      <td>36.791</td>
      <td>1.7</td>
      <td>61.49</td>
      <td>0.571</td>
    </tr>
    <tr>
      <th>92129</th>
      <td>ZWE</td>
      <td>Africa</td>
      <td>Zimbabwe</td>
      <td>2021-05-28</td>
      <td>38918.0</td>
      <td>64.0</td>
      <td>36.286</td>
      <td>1592.0</td>
      <td>0.0</td>
      <td>0.857</td>
      <td>2618.461</td>
      <td>4.306</td>
      <td>2.441</td>
      <td>107.112</td>
      <td>0.000</td>
      <td>0.058</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>976796.0</td>
      <td>656630.0</td>
      <td>320166.0</td>
      <td>23407.0</td>
      <td>12695.0</td>
      <td>6.57</td>
      <td>4.42</td>
      <td>2.15</td>
      <td>854.0</td>
      <td>NaN</td>
      <td>14862927.0</td>
      <td>42.729</td>
      <td>19.6</td>
      <td>2.822</td>
      <td>1.882</td>
      <td>1899.775</td>
      <td>21.4</td>
      <td>307.846</td>
      <td>1.82</td>
      <td>1.6</td>
      <td>30.7</td>
      <td>36.791</td>
      <td>1.7</td>
      <td>61.49</td>
      <td>0.571</td>
    </tr>
    <tr>
      <th>92130</th>
      <td>ZWE</td>
      <td>Africa</td>
      <td>Zimbabwe</td>
      <td>2021-05-29</td>
      <td>38933.0</td>
      <td>15.0</td>
      <td>36.286</td>
      <td>1594.0</td>
      <td>2.0</td>
      <td>1.143</td>
      <td>2619.471</td>
      <td>1.009</td>
      <td>2.441</td>
      <td>107.247</td>
      <td>0.135</td>
      <td>0.077</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>14862927.0</td>
      <td>42.729</td>
      <td>19.6</td>
      <td>2.822</td>
      <td>1.882</td>
      <td>1899.775</td>
      <td>21.4</td>
      <td>307.846</td>
      <td>1.82</td>
      <td>1.6</td>
      <td>30.7</td>
      <td>36.791</td>
      <td>1.7</td>
      <td>61.49</td>
      <td>0.571</td>
    </tr>
  </tbody>
</table>
<p>92131 rows × 59 columns</p>





```python
import numpy as np
import matplotlib.pyplot as plt

locations = ['Japan']
colname = "new_cases_per_million"
plt.figure(figsize=(16,4))
for location in locations:
    df1 = df[df['location'] == location].fillna(0)
    x = np.array(df1['date'], dtype=np.datetime64)
    y = np.array(df1[colname])
    plt.plot(x, y, label=location)

plt.ylabel(colname)
plt.legend()
plt.tight_layout()
plt.savefig("{}.png".format(colname), format="png", dpi=500)
plt.show()
```

![新型コロナ(COVID_19)の感染者・死者・検査・ワクチン接種数の推移_3_0.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/211162/56da99a0-2ace-f37b-2232-26f01f18cef8.png)

    
    



```python
import numpy as np
import matplotlib.pyplot as plt

locations = ['Japan', 'United States', 'United Kingdom']

colname = "new_cases_per_million"
plt.figure(figsize=(16,4))
for location in locations:
    df1 = df[df['location'] == location].fillna(0)
    x = np.array(df1['date'], dtype=np.datetime64)
    y = np.array(df1[colname])
    plt.plot(x, y, label=location)

plt.ylabel(colname)
plt.legend()
plt.tight_layout()
plt.savefig("{}.png".format(colname), format="png", dpi=500)
plt.show()
```


    
![新型コロナ(COVID_19)の感染者・死者・検査・ワクチン接種数の推移_4_0.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/211162/0a8d7bf9-a5a7-edc6-b56e-4200c9ea7ceb.png)

    


# 課題

- 日本、米国、英国における「新規感染者数（百万人あたり）」の推移を図示し、比較してください。
- 日本、米国、英国における「新規死亡者数（百万人あたり）」の推移を図示し、比較してください。
- スウェーデン、イタリア、シンガポール、韓国、台湾、中国についても同様に「新規感染者数（百万人あたり）」と「新規死亡者数（百万人あたり）」の推移を図示し、比較してください。