I'm trying to plot this dataset of COVID-19 deaths as a time series of the number of deaths per country. So far, I've tried this script:
import requests
import pandas as pd
import matplotlib.pyplot as plt
def getdata():
response = requests.get("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv")
with open('data.csv', 'wb') as fp:
fp.write(response.content)
if __name__ == "__main__":
getdata()
df = pd.read_csv('data.csv')
dfg = df.groupby(by='Country/Region').sum()
dfg.drop(labels=['Lat', 'Long'], axis=1, inplace=True)
dfg.columns = pd.to_datetime(dfg.columns)
dfplot = dfg.plot()
plt.show()
which produces a data frame like this:
2020-01-22 2020-01-23 2020-01-24 ... 2020-03-25 2020-03-26 2020-03-27
Country/Region ...
Afghanistan 0 0 0 ... 2 4 4
Albania 0 0 0 ... 5 6 8
Algeria 0 0 0 ... 21 25 26
Andorra 0 0 0 ... 1 3 3
Angola 0 0 0 ... 0 0 0
... ... ... ... ... ... ... ...
Venezuela 0 0 0 ... 0 0 1
Vietnam 0 0 0 ... 0 0 0
West Bank and Gaza 0 0 0 ... 0 1 1
Zambia 0 0 0 ... 0 0 0
Zimbabwe 0 0 0 ... 1 1 1
However, the resulting plot does not show a time series, but rather has different countries on the X-axis:
I've tried reading the DataFrame.plot documentation to see how I could alter this behavior but it's pretty terse. Any ideas how I might accomplish this?


