从我复制到我自己的服务器的已知公共数据集开始。
数据集在这里:https://www.kaggle.com/imdevskp/corona-virus-report/download
import pandas as pd
#df = pd.read_csv("http://g0mesp1res.dynip.sapo.pt/covid_19_clean_complete.csv", index_col=4, parse_dates=True)
df = pd.read_csv("http://g0mesp1res.dynip.sapo.pt/covid_19_clean_complete.csv")
df=df.drop(labels=None, axis=0, index=None, columns=['Province','Lat','Long'], level=None, inplace=False, errors='raise')
#print(df.head())
df['Date']=pd.to_datetime(df['Date'])
#print(df.head())
list_countries = ['Portugal','Brazil','Spain','Italy','Korea, South','Japan']
df= df[df['Country'].isin(list_countries)]
df_pt = df[df.Country == 'Portugal']
df_es = df[df.Country == 'Spain']
df_it = df[df.Country == 'Italy']
print(df_pt.head())
print(df_pt.tail())
我得到了我的期望
Country Date Confirmed Deaths Recovered
59 Portugal 2020-01-22 0 0 0
345 Portugal 2020-01-23 0 0 0
631 Portugal 2020-01-24 0 0 0
917 Portugal 2020-01-25 0 0 0
1203 Portugal 2020-01-26 0 0 0
Country Date Confirmed Deaths Recovered
15503 Portugal 2020-03-16 331 0 3
15789 Portugal 2020-03-17 448 1 3
16075 Portugal 2020-03-18 448 2 3
16361 Portugal 2020-03-19 785 3 3
16647 Portugal 2020-03-20 1020 6 5
但是,绘制时,似乎所有数据都在一月份!
import plotly.graph_objects as go
fig = go.Figure( go.Scatter(x=df.Date, y=df_pt.Confirmed, name='Portugal'))
fig.show()
绘制输出图:
缺少什么?
import plotly.graph_objects as go
fig = go.Figure(go.Scatter(x=df_pt.Date,
y=df_pt.Confirmed,
name='Portugal'))
fig.show()