From f589fc7ce5605d0a9bb3e1e990b9475ec3c9859f Mon Sep 17 00:00:00 2001 From: 10195501441 <10195501441@stu.ecnu.edu.cn> Date: Thu, 24 Dec 2020 18:47:41 +0800 Subject: [PATCH] tring to add some maps --- COVID-19/Project/.vs/Project/v16/.suo | Bin 27648 -> 31232 bytes COVID-19/Project/Project/Project.py | 62 +++++-- COVID-19/Project/Project/Project.pyproj | 4 + COVID-19/Project/Project/province.html | 299 ++++++++++++++++++++++++++++++++ 4 files changed, 350 insertions(+), 15 deletions(-) create mode 100644 COVID-19/Project/Project/province.html diff --git a/COVID-19/Project/.vs/Project/v16/.suo b/COVID-19/Project/.vs/Project/v16/.suo index 68e1f5b40a99707b516ccb6409757bf716d190f0..f22d947a514ce4da1148ead4d863c58f5fc60796 100644 GIT binary patch delta 3679 zcmdTGOH3PAaNl}yHh7(wPcQ^y444!m0ycIEj>Q+*l*h$$I@mZ)z$W#dr&1~6nhVSX4kkBrhy~b04JnA0x~&t~5gGmvHUblhV`gkgh$5l|u?#UE zF%OZZl_1SVq+Jl;#<;Dz%#PHNA+zdyH`1MYdwEtWRjBuAJC%sr5MSarxGCfaK5S1% z9fg~b()dQ5QacCRGf@Xi@L}EP$d%hWenO*bP{O%j(mcsxu*An$JE*2une z6~K&Wuk`D^mv!2Jv`KI8Lb@CA`AjsAC9>ZFmqifCfutJV&mPNZ(L2N-Y=s<)y)ca2 z!-yS-a>fV<`b264^;1tNNs z8e>emh=b_#HDlnBB`=X1gkXL%yqVh~kxS|5Y3JI;Wmw9UB{Glpoo07{TK#syc2K0C zPjfGTDs_nz`)SsBG+dS_O(+qzwO_M5)h(tl>&D6b!Oo}#&w3P)*ZX{d_5=AdXWSYNNATO^@nVse;W%o%x zs|2;Y!^$WtF$-7Zi{;vGSOus-S)wqekWWvK%K|TQ@HFR(zdJOF4vn!0sClbBWufyy zB?J(QG;G{~!SCaOTmv+B{F&u%sA*_|fc(1Y7MDX+4U%#o;S5?CWh<2lV|8W%)rp&? zK9vx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01k&L$)~zD=lt*91<;2k&ajjj_N4&4A#pBjhxs^Pk^cx;xDa=RKJII z2rJ)D`QoXt7G`~moI|!Q32qI}>=BXJO{b~R-C(V9HNA33%i&(tf{~M0tz9Ly^^oYf zZ{+pQ9+PdTuO@6{FX9Rnl&Vlib%gh8T;NtnIFeikS;r9EZSulw(;~>TT3!w7Eep>P zF42Xm=yg$b^B&07JlK^0rBNj*MC+%!krAf%QXwZedp{QFWl~pQt@nGuR3K1eT$mJ3 zaw{Rw8|uE12PVAIv|rlkcN+9n5DsEkQp3>8^g{|17Y3GE={T; zXykU>@mx6rbJz*iAy0Zaw#@%FfoiO`?^1<4rrAHpTSQ?Qy>_Y^y^=Nt8)XCkrex^* zQCKoMrDTu=NLn&M#8pl0!i$JV+1QaHBuX*m9vgfYI|B2sIH1mI-rpYVbajT>+T9YT zHxJ(FK2k#ENUe2hZfbh+!Xm6%-4Gag(WihHe*OHC zz2oudt%v7MUHfqS_a__K0V|^~lTJ|#Ur+fAOv2w4*2-4WZ*?bmT8?M;WYeBP?9>LFSU9qEB*p zy?(FD^Gs|~^_ktPARP#wD*itt?RAjO22u?I?757gm@99rU|hr4xDubOzjN48y#5-~ zyE6?IpD*ZfwRiOST^^6O-Q{;nlIyU)Ps+y_HqTT+U41QuxqORW3Y}0NQXD@$A=U*s GyYwg817;@x diff --git a/COVID-19/Project/Project/Project.py b/COVID-19/Project/Project/Project.py index 38784da..4a6277e 100644 --- a/COVID-19/Project/Project/Project.py +++ b/COVID-19/Project/Project/Project.py @@ -5,6 +5,8 @@ import numpy as np import datetime import math from scipy import interpolate +from pyecharts.charts import Map +from pyecharts import options plt.rcParams['axes.unicode_minus'] = False @@ -37,7 +39,6 @@ dfChinaSept = China[China['Date'].dt.month == 9] dfChinaOct = China[China['Date'].dt.month == 10] dfChinaNov = China[China['Date'].dt.month == 11] dfChinaDec = China[China['Date'].dt.month == 12] - dfUSJan = US[US['Date'].dt.month == 1] dfUSFeb = US[US['Date'].dt.month == 2] dfUSMar = US[US['Date'].dt.month == 3] @@ -58,7 +59,6 @@ recoveredChina = [dfChinaJan['Recovered'].sum(),dfChinaFeb['Recovered'].sum(),df dfChinaMay['Recovered'].sum(),dfChinaJun['Recovered'].sum(),dfChinaJul['Recovered'].sum(),dfChinaAug['Recovered'].sum(), dfChinaSept['Recovered'].sum(),dfChinaOct['Recovered'].sum(),dfChinaNov['Recovered'].sum(),dfChinaDec['Recovered'].sum()] recoverPossChina = [] - confirmedUS = [dfUSJan['Confirmed'].sum(),dfUSFeb['Confirmed'].sum(),dfUSMar['Confirmed'].sum(),dfUSApr['Confirmed'].sum(), dfUSMay['Confirmed'].sum(),dfUSJun['Confirmed'].sum(),dfUSJul['Confirmed'].sum(),dfUSAug['Confirmed'].sum(), dfUSSept['Confirmed'].sum(),dfUSOct['Confirmed'].sum(),dfUSNov['Confirmed'].sum(),dfUSDec['Confirmed'].sum()] @@ -102,28 +102,41 @@ datasUS = data3 + data4 + data5 labsUS = [d.get_label() for d in datasUS] ax3.legend(datasUS, labsUS, loc="upper left") - -dataNew = pd.melt(China[['Date','Province/State','Confirmed','Recovered','Deaths']], +#中国各省数据 +dataChina = pd.melt(China[['Date','Province/State','Confirmed','Recovered','Deaths']], id_vars=['Date','Province/State'],value_vars=['Confirmed','Recovered','Deaths'], var_name='group_var',value_name='Cases') -dataNew['Date'] = pd.to_datetime(dataNew['Date']) -dfNew = China[['Province/State','Confirmed','Recovered','Deaths']].groupby(['Province/State']).sum().reset_index() -dataNew = pd.melt(dfNew,id_vars=['Province/State'], +dataChina['Date'] = pd.to_datetime(dataChina['Date']) +dfChina = China[['Province/State','Confirmed','Recovered','Deaths']].groupby(['Province/State']).sum().reset_index() +dataChina = pd.melt(dfChina,id_vars=['Province/State'], + value_vars=['Confirmed','Deaths','Recovered'], + var_name='group_var',value_name='Cases') +dataChina = dataChina.sort_values(by=['Province/State','group_var']).reset_index(drop=True) +dataChina = dataChina.pivot_table(index=['Province/State'], columns='group_var') +dataChina.columns = dataChina.columns.droplevel().rename(None) + +#各国数据 +dataWorld = pd.melt(dataset[['Date','Country/Region','Confirmed','Recovered','Deaths']], + id_vars=['Date','Country/Region'],value_vars=['Confirmed','Recovered','Deaths'], + var_name='group_var',value_name='Cases') +dataWorld['Date'] = pd.to_datetime(dataWorld['Date']) +dfWorld = dataset[['Country/Region','Confirmed','Recovered','Deaths']].groupby(['Country/Region']).sum().reset_index() +dataWorld = pd.melt(dfWorld,id_vars=['Country/Region'], value_vars=['Confirmed','Deaths','Recovered'], var_name='group_var',value_name='Cases') -dataNew = dataNew.sort_values(by=['Province/State','group_var']).reset_index(drop=True) -dataNew = dataNew.pivot_table(index=['Province/State'], columns='group_var') -dataNew.columns = dataNew.columns.droplevel().rename(None) +dataWorld = dataWorld.sort_values(by=['Country/Region','group_var']).reset_index(drop=True) +dataWorld = dataWorld.pivot_table(index=['Country/Region'], columns='group_var') +dataWorld.columns = dataWorld.columns.droplevel().rename(None) #中国各省份 -dataNew.sort_values('Confirmed', inplace=True) +dataChina.sort_values('Confirmed', inplace=True) xData = [] yConfirmed = [] yRecovered = [] for i in range(12): - xData.append(dataNew.index[i]) - yConfirmed.append(dataNew['Confirmed'][i]) - yRecovered.append(dataNew['Recovered'][i]) + xData.append(dataChina.index[i]) + yConfirmed.append(dataChina['Confirmed'][i]) + yRecovered.append(dataChina['Recovered'][i]) ax5 = fig.add_subplot(212) ax5.set_title("Total Recovered/Confirmed of China(the bottom ten)",verticalalignment="bottom",fontsize="13") @@ -134,4 +147,23 @@ ax5.bar(r1, yConfirmed, color='#FF0088', width=barWidth, edgecolor='white', labe ax5.bar(r2, yRecovered, color='#00BBFF', width=barWidth, edgecolor='white', label='Recovered') plt.xticks([r + barWidth for r in range(len(yConfirmed))], xData) ax5.legend() -plt.show() \ No newline at end of file + +plt.show() + +ChinaConfirmed=[] +worldConfirmed=[] + +for i in range(33): + ChinaConfirmed.append((dataChina.index[i],dataChina['Confirmed'][i])) + +map_China = Map() +map_China.set_global_opts(title_opts=options.TitleOpts(title="疫情图-确诊人数"), + visualmap_opts=options.VisualMapOpts(is_piecewise=True, + pieces=[ + {"min": 1000, "label": '>1000人',"color": "#6F171F"}, + {"min": 500, "max": 1000,"label": '500-1000人', "color": "#C92C34"}, + {"min": 100, "max": 499,"label": '100-499人', "color": "#E35B52"}, + {"min": 10, "max": 99,"label": '10-99人', "color": "#F39E86"}, + {"min": 1, "max": 9, "label": '1-9人', "color": "#FDEBD0"}])) +map_China.add("确诊", ChinaConfirmed, maptype='china') +map_China.render("province.html") \ No newline at end of file diff --git a/COVID-19/Project/Project/Project.pyproj b/COVID-19/Project/Project/Project.pyproj index e3febd4..2400ed9 100644 --- a/COVID-19/Project/Project/Project.pyproj +++ b/COVID-19/Project/Project/Project.pyproj @@ -11,6 +11,7 @@ . Project Project + CondaEnv|CondaEnv|env true @@ -23,6 +24,9 @@ + + +