The Coronavirus virus has upended our daily lives, spreading exponentially in recent days, especially in places like New York and Italy, and showing no signs of abating.
There have been excellent visuals that capture the spread of the Coronavirus, and I want to show you how to create some of them with Python. Python has quite a few options when it comes to creating graphs, one option being plotly, an outstanding package that provides powerful visuals. This article will focus on using plotly to create bubble maps that show spread of the Coronavirus across the United States.
To get started, import the following modules:
Next download my covid-19 dataset, which I originally downloaded from Kaggle (I cleaned the data a bit, since the format of the states in Province_State column were inconsistent):
Next, we are going to create a widget that allows to you to pick a date, subsequently generating a bubble graph that shows the count of confirmed cases across the US:
After we’ve created our Date Picker, we filter our dataset based on a date that is chosen:
Now we’ll create our graph. I created comments to describe what the code does:
Once you’ve run this block of code, a date picker along with a bubble graph of Coronavirus cases in the US on January 27th will be displayed:
There were only a handful cases on that day, but if you were to choose a more recent day, March 20th, for example, then the map will change dramatically:
I find this to be a very informative and powerful way to capture the spread of the virus — it’s personally my favorite. However, I’ll quickly demonstrate how to create an alternative graph to track the spread of the virus in the US:
Like before, not too much is going on January 27th, but if we fast-forward to the March 20th, we’ll see a remarkable change:
In summary, these are two examples of how you can use Python to convey information in both a powerful and direct way, allowing the audience to easily grasp the gravity of the situation we currently find ourselves in. Be well. Be safe!