In [1]:
import pandas as pd
from datetime import datetime as dt, timedelta as td
import bokeh.plotting as bkp
from seabornify import seabornify
bkp.output_notebook()
The Wikipedia page has proven to be a very helpful and up to date resource, and even contains a timeline with a running tally of casualties, aggregated from various official reports.
However, the few graphics on that page do not include breakdowns by country, so I decided to reflow the data through Bokeh.
These data are pulled from @cmyeaton's repository on GitHub (https://github.com/cmrivers/ebola) and are current as of September 10th, 2014. Rerunning this notebook should provide an updated view, assuming the data format does not change.
In [2]:
df = pd.read_csv('https://raw.githubusercontent.com/cmrivers/ebola/master/country_timeseries.csv',
index_col=0, parse_dates=True)
df.sort(inplace=True)
df.head()
Out[2]:
In [3]:
# set y_range of all plots to the same maximum value for accurate magnitude comparison
max_y = df.max().max() * 1.1
countries = ["Guinea", "Liberia", "SierraLeone", "Nigeria", "Senegal"]
plots = []
for country in countries:
bkp.figure(title="Ebola Cases, Deaths in %s" %country,
x_axis_type="datetime",
y_range=(0, max_y),
plot_width=600, plot_height=300,
orientation="top_left", tools='')
bkp.hold()
cols = [x for x in df.columns if country in x]
for col in cols:
if "Deaths" in col:
color="red"
legend="Deaths"
else:
color="black"
legend="Cases"
bkp.line(list(df.index), df[col],
color=color, legend=legend,
linewidth=2, alpha=0.9)
bkp.legend().orientation = "top_left"
plot = bkp.curplot()
seabornify(plot)
plots.append(plot)
In [4]:
for plot in plots:
bkp.show(plot)
In the plots above, Liberia stood out quite a bit. The outbreak there has taken on an accelerated pace in the past couple of weeks.
In [6]:
# Liberia plot
country = "Liberia"
bkp.figure(title="Ebola Cases, Deaths in %s" %country,
x_axis_type="datetime",
y_range=(0, max_y),
plot_width=600, plot_height=300,
orientation="top_left", tools='')
bkp.hold()
cols = [x for x in df.columns if country in x]
for col in cols:
if "Deaths" in col:
color="red"
legend="Deaths"
else:
color="black"
legend="Cases"
bkp.line(list(df.index), df[col],
color=color, legend=legend,
linewidth=2, alpha=0.9)
latest = df.index.max()
two_weeks = latest - td(days=14)
two_months = latest - td(days=60)
bkp.quad([two_weeks], [latest], [max_y], [0], alpha=0.2, color="gray")
bkp.quad([two_months], [latest], [max_y], [0], alpha=0.2, color="gray")
bkp.legend().orientation = "top_left"
plot = bkp.curplot()
seabornify(plot)
bkp.show(plot)