集智俱乐部计算传播学

2019ncov细颗粒度历史数据

2020-02-19  本文已影响0人  c0659eed21f5

epidemic_hist_all()
NCP细化到地市的细颗粒数据
https://github.com/norratek/Ncov2020HistoryData
https://docs.google.com/spreadsheets/d/1JNQnFYJpR7PxQo5K5lwXTuE0F6jprhMXuy7DPnV9H90/edit#gid=0
:return: 返回每日的历史数据
:rtype: pandas.DataFrame</pre>

import akshare as ak
import pylab as plt
plt.style.use('fivethirtyeight')

epidemic_hist_all_df = ak.epidemic_hist_all()

提取江苏省的历史数据

epidemic_hist_all_df = epidemic_hist_all_df.sort_values(by='date')
js = epidemic_hist_all_df[epidemic_hist_all_df['Province']=='江苏省']
js.head()
江苏历史数据

看一下南京市的数据

plt.figure(figsize=(12, 6), dpi = 200)
i = '南京'
df = js[js['City']==i]
plt.plot(df['date'], df['Confirmed'],
         'r-s', label = '累计确诊')
plt.plot(df['date'], df['Cured'],
         'g-o', label = '累计治愈')
plt.title(i, fontsize =20)
plt.legend()
# plt.yscale('log')
plt.xticks(rotation=60)
plt.ylabel('数量', fontsize = 20)
plt.show()
南京市

江苏所有地级市数据

cols =  [ '#bd2309', '#bbb12d', '#1480fa', '#14fa2f', '#000000',
              '#faf214', '#2edfea', '#ea2ec4', '#ea2e40', '#cdcdcd',
              '#577a4d', '#2e46c0', '#f59422', '#219774', '#8086d9' ]
    
plt.figure(figsize=(12, 6), dpi = 200)
for k, i in enumerate(js['City'].unique()):
    df = js[js['City']==i]
    plt.plot(df['date'], df['Confirmed'], color= cols[k], marker='o', linestyle='-',
              label = i)
plt.title('江苏省', fontsize =20)
plt.legend()
# plt.yscale('log')
plt.xticks(rotation=60)
plt.ylabel('累计确诊数量', fontsize = 20)
plt.show()
江苏所有地级市
上一篇下一篇

猜你喜欢

热点阅读