Changes in coronavirus infection rate

at first

I am not an infectious disease expert, so please read it with an understanding.

The number of people infected with coronavirus is increasing every day. The Ministry of Health, Labor and Welfare page does not have open data that is easy to use, but there are prefectures that publish data on open data portal sites. Since we have data on the number of PCR tests and the number of infected people, we looked at the changes in the number of infected people.

I updated the graph with the data one week later, and it can be seen that the infection rate is lower than last week.

Since the data of Saitama prefecture is easy to use, we investigated the transition of the infection rate from the number of PCR tests and the number of infected people in Saitama prefecture. However, since the data of Saitama Prefecture is written as the number of inspections (total number of people), not the number of inspections, Infection rate = number of infected people / number of tests (total number of people) Is being calculated.

If the data format for each prefecture was unified, other prefectures could be examined immediately, but unfortunately it was not unified.

Changes in infection rate

import pandas as pd
import matplotlib.pyplot as plt
data = pd.read_csv('data/saitama_kensa_20200418.csv')
data.columns = ['day', 'PCR', 'Confirmed']
print(data.head())
print(data.tail())

The data of the number of PCR tests is from 2020/1/31 to 2020/4/18.

         day  PCR  Confirmed
0  2020/1/31    1          0
1   2020/2/1    1          0
2   2020/2/2    0          0
3   2020/2/3    0          0
4   2020/2/4    1          0
          day  PCR  Confirmed
74  2020/4/14   37          7
75  2020/4/15  110         28
76  2020/4/16  147         21
77  2020/4/17   70          9
78  2020/4/18  100         21
plt.plot(data.loc[:,'PCR'])
plt.plot(data.loc[:,'Confirmed'])
plt.xlabel('day')
plt.ylabel('Number')
plt.legend()
plt.savefig('fig1.png')

Posted on April 19, 2020 fig1.png Posted on April 27, 2020 saitama_kensa_fig1_20200426.png

Since the daily infection rate fluctuates greatly, we also display the 7-day moving average. The moving average was below 10% for the first 50 days, but has since risen to around 20%.

rate = data.loc[:,'Confirmed']/data.loc[:,'PCR'].fillna(0.0)
rate_ma = rate.rolling(7).mean().fillna(0)
plt.plot(rate * 100, label='rate', linewidth=1)
plt.plot(rate_ma * 100, label='rate_ma', linewidth=3)
plt.ylim(0.0, 30.0)
plt.xlabel('day')
plt.ylabel('Rate(%)')
plt.legend()
plt.savefig('fig2.png')

Posted on April 19, 2020 fig2.png Posted on April 27, 2020 saitama_kensa_fig2_20200426.png According to the data on April 19, 2020, the moving average of the infection rate was around 20%. However, according to the data on April 26, 2020, it has dropped to around 10%.

We hope that refraining from going out will reduce the number of infected people.

Recommended Posts

Changes in coronavirus infection rate
Assignments and changes in Python objects
Draw retention rate graph in Matplotlib