[PYTHON] Plot the spread of the new coronavirus

I used Python's Plotly library. With Geojson, it is attractive to be able to easily plot as an animation on a map from a data frame. On the other hand, the problem is that it is overwhelmingly heavier than Javascript.

Github link

japan_animation_small.gif

Number of infected people by prefecture

a.PNG Number of infected people by country

aa.PNG

Number of infected people in China

Code commentary

###Data frame reading
dfs = []
for l in os.listdir("./csv_ja/"):
    if ".csv" in l:
        dfs.append(pd.read_csv("./csv_ja/" +l))
    print(l)

###json read
with open("./geo_data/jp_prefs.geojson") as f:
    geojson_japan = json.load(f)

###Creating an Animation Object
fig = px.choropleth(df_japan,
                    geojson = geojson_japan,
                    featureidkey="properties.NAME_JP",
                    locations="Province/State",
                    color="Confirmed",
                    hover_name="Province/State",
                    color_continuous_scale="PuRd",
                    projection="mercator",
                    animation_frame="date",
                    range_color=(0,df_japan[key].max()),
                    width=600, height=800)
fig.update_geos(fitbounds="locations", visible=False)
fig.update_layout(
    title="Number of people infected with new coronavirus(Prefectures)")

Secondary source

Johns Hopkins University Dashboard Johns Hopkins University Spreadsheet

Primary source

MIT (Prefecture Geojson Data) WHO NHC CDC Dingxiangyuan Ministry of Health, Labor and Welfare

The day when positive is confirmed is defined as Confirmed. The prefecture means the prefecture where you live (in the case of foreign nationality, the prefecture of the medical institution where you visited). Asymptomatic pathogen carriers are not included in infected individuals.

Recommended Posts

Plot the spread of the new coronavirus
Estimate the peak infectivity of the new coronavirus
Factfulness of the new coronavirus seen in Splunk
GUI simulation of the new coronavirus (SEIR model)
Let's test the medical collapse hypothesis of the new coronavirus
Analyzing the age-specific severity of coronavirus
Quantify the degree of self-restraint required to contain the new coronavirus
(Now) I analyzed the new coronavirus (COVID-19)
I tried using PDF data of online medical care based on the spread of the new coronavirus infection
Did the number of store closures increase due to the impact of the new coronavirus?
The story of the student who developed the new coronavirus countermeasure site (Ishikawa version)
Let's calculate the transition of the basic reproduction number of the new coronavirus by prefecture
I tried to predict the behavior of the new coronavirus with the SEIR model.
Folding @ Home on Linux Mint to contribute to the analysis of the new coronavirus
I touched some of the new features of Python 3.8 ①
Scraping the number of downloads and positive registrations of the new coronavirus contact confirmation app
The epidemic forecast of the new coronavirus was released on the Web at explosive speed
I tried to automatically send the literature of the new coronavirus to LINE with Python
The beginning of cif2cell
Let's examine the convergence time from the global trend of the effective reproduction number of the new coronavirus
The meaning of self
[Statistics] Understand the mechanism of Q-Q plot by animation.
Verify the effect of leave as a countermeasure against the new coronavirus with the SEIR model
the zen of Python
Drawing on Jupyter using the plot function of pandas
The story of sys.path.append ()
The theory that the key to controlling infection with the new coronavirus is hyperdispersion of susceptibility
I tried to visualize the characteristics of new coronavirus infected person information with wordcloud
Let's put out a ranking of the number of effective reproductions of the new coronavirus by prefecture
Tasks at the start of a new python project
Enlarge the plot display.
Revenge of the Types: Revenge of types
Use hash to lighten collision detection of about 1000 balls in Python (related to the new coronavirus)
I tried to tabulate the number of deaths per capita of COVID-19 (new coronavirus) by country
Let's simulate the effect of introducing a contact tracking app as a countermeasure against the new coronavirus
Significance of narrowing down the test target of PCR test for new coronavirus understood by Bayes' theorem
I analyzed tweets about the new coronavirus posted on Twitter
Kill analysis of the popular game PUPG. Use seaborn-pair plot.
[python] plot the values ​​before and after the conversion of yeojohnson conversion
Reformat the timeline of the pandas time series plot with matplotlib
Let's visualize the number of people infected with coronavirus with matplotlib
Align the version of chromedriver_binary
Scraping the result of "Schedule-kun"
10. Counting the number of lines
The story of building Zabbix 4.4
Towards the retirement of Python2
[Apache] The story of prefork
Compare the fonts of jupyter-themes
About the ease of Python
Get the number of digits
Explain the code of Tensorflow_in_ROS
Hypothesis of why the new coronavirus is not so common in urban areas such as Tokyo
Reuse the results of clustering
GoPiGo3 of the old man
Calculate the number of changes
Change the theme of Jupyter
The popularity of programming languages
Change the style of matplotlib
Visualize the orbit of Hayabusa2
About the components of Luigi
Connected components of the graph