From 177abba9feeffff06db0b88cc7d20b95ce706a20 Mon Sep 17 00:00:00 2001 From: 10195501441 <10195501441@stu.ecnu.edu.cn> Date: Sun, 27 Dec 2020 17:03:49 +0800 Subject: [PATCH] optimized the categories --- COVID-19/Project/.vs/Project/v16/.suo | Bin 30208 -> 0 bytes COVID-19/Project/Project.sln | 23 - COVID-19/Project/Project/China.html | 267 ------ COVID-19/Project/Project/Project.py | 193 ---- COVID-19/Project/Project/Project.pyproj | 39 - COVID-19/Project/Project/world.html | 1007 -------------------- COVID-19/Visualization/.vs/Visualization/v16/.suo | Bin 0 -> 29696 bytes COVID-19/Visualization/Project/China.html | 267 ++++++ COVID-19/Visualization/Project/Visualization.py | 193 ++++ .../Visualization/Project/Visualization.pyproj | 40 + COVID-19/Visualization/Project/world.html | 1007 ++++++++++++++++++++ COVID-19/Visualization/Visualization.sln | 23 + 12 files changed, 1530 insertions(+), 1529 deletions(-) delete mode 100644 COVID-19/Project/.vs/Project/v16/.suo delete mode 100644 COVID-19/Project/Project.sln delete mode 100644 COVID-19/Project/Project/China.html delete mode 100644 COVID-19/Project/Project/Project.py delete mode 100644 COVID-19/Project/Project/Project.pyproj delete mode 100644 COVID-19/Project/Project/world.html create mode 100644 COVID-19/Visualization/.vs/Visualization/v16/.suo create mode 100644 COVID-19/Visualization/Project/China.html create mode 100644 COVID-19/Visualization/Project/Visualization.py create mode 100644 COVID-19/Visualization/Project/Visualization.pyproj create mode 100644 COVID-19/Visualization/Project/world.html create mode 100644 COVID-19/Visualization/Visualization.sln diff --git a/COVID-19/Project/.vs/Project/v16/.suo b/COVID-19/Project/.vs/Project/v16/.suo deleted file mode 100644 index b40ba65a5c6c3e6a82d4bf5cd8ef867597943ab0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 30208 zcmeHPTZ~&r89q+3xiy5gDM`~7>Xwj(bnW_nNjI0hCfjD4O?IZ10 zabV19m$Xq}PvU7yzT}?n!DRhwwI9zz6an0YzLT=71 z@GPHNy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0@G%u;&*>CN;v2+yw7c_1d> zGhd09e40{ASyv#3s7#~kCQtWDtzmzM>-IQW*6G&LH-zVtrMI6|vuUO?9qo91=*z~? zuK(uE?EmTM^@i8h|MOeoT#M}C+SgY<5{uZ+0{t5fzH{KKbbtiW=hmVH-|ITf$|4TRMcD1K!Bgm3X>%~TGz%?-`4K9grB;@tQ z!>(vF`{AMG2N%bQ9I^| zM?J}8GVWg4jPEB z)G;}qh9^m?2*;Cby5OEniOuPq@N^K)D~Ib~pVSM*+Nj+VrR+#5tq;YD zF*f9(KBiTkEBsNxuws@i*}QZW%v0jKWVl%dO!5tt2basZB0s`%ee{|3Uo! z5p^flp$Tg7xzqpuz}+6&6Yb)kLE7&BKZv0)?UJ>9{!`e0Tk(IPy`+QZKU<#vX8JGh z63X`9Zs$L(?U($x0Q*Vz{GZM9e=XA=Z6<2}q0#!+J^xql)S={EyyE=M(Su4p`9CeI*?bKcSucoX09Z9uacK#Le!7nK^L0GYI`RT}K10 zIzF*#o!8v|?d<5wO7s7>r-d9{#9jFi(D#V@nLNjs5@$xIk(`$KvOj@pwkk*6DWh9M ztvIHs6~CG|`ZL(|bWnBV9%vF!ZdvC%C8~WR=;5^lG19|P>hY3V zb8AGcR=g?jy$Jf3l*4}&UXSsV=g=>s#oXoOe|W4PEm1E>uWM_Y`LEjL({?=4tfOmZ z{puV|)61vY4^R2WS=Y_A#w%+>+FGkQT-o00H4dmn==%Rjp2p6gA48?ISzCU(hIICv zo4WpAaCmI*uaj;G|1S_q*Z&8dz*7UXVRzCusq6oP4s8;;{y&nd^FMs5y(zl>Ka>*q zZ#3QWKWlUT=fiS$>H7azj&qs(FFN46(}5y7?Edo|Ft}3y8XU{+KVAQy)w};_tMUK& EKQIG59{>OV diff --git a/COVID-19/Project/Project.sln b/COVID-19/Project/Project.sln deleted file mode 100644 index b0021a6..0000000 --- a/COVID-19/Project/Project.sln +++ /dev/null @@ -1,23 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30717.126 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "Project", "Project\Project.pyproj", "{7BBACCFA-5595-4614-93C7-7E130A65B9AA}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7BBACCFA-5595-4614-93C7-7E130A65B9AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7BBACCFA-5595-4614-93C7-7E130A65B9AA}.Release|Any CPU.ActiveCfg = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {0D9731B0-0B1C-46C6-A604-021D09B35A11} - EndGlobalSection -EndGlobal diff --git a/COVID-19/Project/Project/China.html b/COVID-19/Project/Project/China.html deleted file mode 100644 index a9ee0b1..0000000 --- a/COVID-19/Project/Project/China.html +++ /dev/null @@ -1,267 +0,0 @@ - - - - - Awesome-pyecharts - - - - - -
- - - diff --git a/COVID-19/Project/Project/Project.py b/COVID-19/Project/Project/Project.py deleted file mode 100644 index f737ed3..0000000 --- a/COVID-19/Project/Project/Project.py +++ /dev/null @@ -1,193 +0,0 @@ -import pandas as pd -import matplotlib.pyplot as plt -import matplotlib.dates as mdates -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 - -#打开数据文件 -dataset = pd.read_csv('E:\dase intro\COVID-19Analysis\COVID-19\covid-19-all.csv') - -#数据预处理 -def parse_ymd(s): - year_s, mon_s, day_s = s.split('-') - return datetime.datetime(int(year_s), int(mon_s), int(day_s)).strftime("%Y-%m-%d") - -dataset = dataset.fillna(0) - -dataset['Date'] = pd.to_datetime(dataset['Date']) - -#对China\US数据进行可视化操作 -China = dataset[dataset['Country/Region'] == 'China'].reset_index(drop=True) -US = dataset[dataset['Country/Region'] == 'US'].reset_index(drop=True) - -#计算中\美每日治愈率/确诊人数/治愈人数(分月份显示) -dfChinaJan = China[China['Date'].dt.month == 1] -dfChinaFeb = China[China['Date'].dt.month == 2] -dfChinaMar = China[China['Date'].dt.month == 3] -dfChinaApr = China[China['Date'].dt.month == 4] -dfChinaMay = China[China['Date'].dt.month == 5] -dfChinaJun = China[China['Date'].dt.month == 6] -dfChinaJul = China[China['Date'].dt.month == 7] -dfChinaAug = China[China['Date'].dt.month == 8] -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] -dfUSApr = US[US['Date'].dt.month == 4] -dfUSMay = US[US['Date'].dt.month == 5] -dfUSJun = US[US['Date'].dt.month == 6] -dfUSJul = US[US['Date'].dt.month == 7] -dfUSAug = US[US['Date'].dt.month == 8] -dfUSSept = US[US['Date'].dt.month == 9] -dfUSOct = US[US['Date'].dt.month == 10] -dfUSNov = US[US['Date'].dt.month == 11] -dfUSDec = US[US['Date'].dt.month == 12] - -confirmedChina = [dfChinaJan['Confirmed'].sum(),dfChinaFeb['Confirmed'].sum(),dfChinaMar['Confirmed'].sum(),dfChinaApr['Confirmed'].sum(), - dfChinaMay['Confirmed'].sum(),dfChinaJun['Confirmed'].sum(),dfChinaJul['Confirmed'].sum(),dfChinaAug['Confirmed'].sum(), - dfChinaSept['Confirmed'].sum(),dfChinaOct['Confirmed'].sum(),dfChinaNov['Confirmed'].sum(),dfChinaDec['Confirmed'].sum()] -recoveredChina = [dfChinaJan['Recovered'].sum(),dfChinaFeb['Recovered'].sum(),dfChinaMar['Recovered'].sum(),dfChinaApr['Recovered'].sum(), - 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()] -recoveredUS = [dfUSJan['Recovered'].sum(),dfUSFeb['Recovered'].sum(),dfUSMar['Recovered'].sum(),dfUSApr['Recovered'].sum(), - dfUSMay['Recovered'].sum(),dfUSJun['Recovered'].sum(),dfUSJul['Recovered'].sum(),dfUSAug['Recovered'].sum(), - dfUSSept['Recovered'].sum(),dfUSOct['Recovered'].sum(),dfUSNov['Recovered'].sum(),dfUSDec['Recovered'].sum()] -recoverPossUS = [] - -for i in range(len(confirmedChina)): - recoverPossChina.append(recoveredChina[i] / confirmedChina[i]) - recoverPossUS.append(recoveredUS[i] / confirmedUS[i]) - -#x轴为日期(月份) -date = pd.date_range(start='2020-01', periods=12, freq="m").strftime('%m') - -fig = plt.figure() - -#中国 -ax1 = fig.add_subplot(221) -ax1.set_title("Recovered/Confirmed/Recovery Possibility(month) of China",verticalalignment="bottom",fontsize="13") -data1 = ax1.plot(date,confirmedChina,color="red",linewidth="1.7",label="confirmed") -data2 = ax1.plot(date,recoveredChina,color="lime",linewidth="1.7",label="recovered") -ax1.set_ylabel('recovered/confirmed') -ax2 = ax1.twinx() -ax2.set_ylabel('recovery possibility') -data3 = ax2.plot(date,recoverPossChina,color="blue",linestyle="--",linewidth="1.0",label="recovery possibility") -datasChina = data1 + data2 + data3 -labsChina = [d.get_label() for d in datasChina] -ax1.legend(datasChina, labsChina, loc="lower right") - -#美国 -ax3 = fig.add_subplot(222) -ax3.set_title("Recovered/Confirmed/Recovery Possibility(month) of US",verticalalignment="bottom",fontsize="13") -data3 = ax3.plot(date,confirmedUS,color="red",linewidth="1.7",label="confirmed") -data4 = ax3.plot(date,recoveredUS,color="lime",linewidth="1.7",label="recovered") -ax3.set_ylabel('recovered/confirmed') -ax4 = ax3.twinx() -ax4.set_ylabel('recovery possibility') -data5 = ax4.plot(date,recoverPossUS,color="blue",linestyle="--",linewidth="1.0",label="recovery possibility") -datasUS = data3 + data4 + data5 -labsUS = [d.get_label() for d in datasUS] -ax3.legend(datasUS, labsUS, loc="upper left") - -#中国各省数据 -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') -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') -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) - -#中国省份(bottom 12) -dataChina.sort_values('Confirmed', inplace=True) -xData = [] -yConfirmed = [] -yRecovered = [] -for i in range(12): - 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") -barWidth = 0.25 -r1 = np.arange(12) -r2 = [x + barWidth for x in r1] -ax5.bar(r1, yConfirmed, color='#FF0088', width=barWidth, edgecolor='white', label='Confirmed') -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() - -#中国疫情图 -ChinaConfirmed = [] -ChinaProvince = [] -worldConfirmed = [] -provinceNameMap = {'Tibet':'西藏', 'Qinghai':'青海', 'Macau':'澳门', 'Ningxia':'宁夏', 'Jilin':'吉林', 'Guizhou':'贵州', - 'Gansu':'甘肃', 'Hainan':'海南', 'Shanxi':'山西', 'Yunnan':'云南', 'Liaoning':'辽宁', 'Tianjin':'天津', - 'Inner Mongolia':'内蒙古', 'Guangxi':'广西', 'Shaanxi':'陕西', 'Hebei':'河北', 'Fujian':'福建', 'Xinjiang':'新疆', - 'Chongqing':'重庆', 'Sichuan':'四川', 'Jiangsu':'江苏', 'Beijing':'北京', 'Shanghai':'上海', 'Shandong':'山东', - 'Heilongjiang':'黑龙江', 'Jiangxi':'江西', 'Anhui':'安徽', 'Hunan':'湖南', 'Zhejiang':'浙江', 'Henan':'河南', - 'Guangdong':'广东', 'Hong Kong':'香港', 'Hubei':'湖北'} - -for i in range(33): - ChinaConfirmed.append(dataChina['Confirmed'][i]) - ChinaProvince.append(provinceNameMap[dataChina.index[i]]) - - -map_China = Map() -map_China.set_global_opts(title_opts=options.TitleOpts(title="中国(大陆)疫情图-总确诊人数"), - legend_opts=options.LegendOpts(is_show=False), - visualmap_opts=options.VisualMapOpts(max_=200000)) -map_China.add("",[list(z) for z in zip(ChinaProvince, ChinaConfirmed)], maptype='china') -map_China.render("China.html") - -#世界地图 -worldConfirmed = [] -worldName = [] -for i in range(dataWorld.shape[0]): - worldConfirmed.append(dataWorld['Confirmed'][i]) - if dataWorld.index[i] == 'US': - worldName.append('United States') - else: - worldName.append(dataWorld.index[i]) - -map_world = Map() -map_world.set_global_opts(title_opts=options.TitleOpts(title="世界疫情图-总确诊人数"), - legend_opts=options.LegendOpts(is_show=True), - visualmap_opts=options.VisualMapOpts(min_=10000,max_=80000000)) -map_world.add("",[list(z) for z in zip(worldName, worldConfirmed)], maptype='world') -map_world.render("world.html") - - diff --git a/COVID-19/Project/Project/Project.pyproj b/COVID-19/Project/Project/Project.pyproj deleted file mode 100644 index 2400ed9..0000000 --- a/COVID-19/Project/Project/Project.pyproj +++ /dev/null @@ -1,39 +0,0 @@ - - - Debug - 2.0 - 7bbaccfa-5595-4614-93c7-7e130a65b9aa - . - Project.py - - - . - . - Project - Project - CondaEnv|CondaEnv|env - - - true - false - - - true - false - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/COVID-19/Project/Project/world.html b/COVID-19/Project/Project/world.html deleted file mode 100644 index c2d7e9d..0000000 --- a/COVID-19/Project/Project/world.html +++ /dev/null @@ -1,1007 +0,0 @@ - - - - - Awesome-pyecharts - - - - - -
- - - diff --git a/COVID-19/Visualization/.vs/Visualization/v16/.suo b/COVID-19/Visualization/.vs/Visualization/v16/.suo new file mode 100644 index 0000000000000000000000000000000000000000..312217de6b494690867aa74ffbd4b30f153a0e93 GIT binary patch literal 29696 zcmeHQYiwM_6~0Swhz+EW&_E!CO&UT9-euqG1t;;F7-HgJ#{pt6>)pHNChOg0A0bX` zD6~RCLKS_f{ZaMxt4~!({ZrJcQ1$Vr5>44q<;{e|Mm=1vY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J&MB{Ji1HdEBk7V!%3IHI$)M0E1~4QBMgWODRuF0U78yfLPB z;WGm`wQ&X(d_wrMxqoFI9HVLHfFpwIW`rM1iJl@Xe(r+FBGwFeZ`QIlJPRM-lo?9- z;Ki=2K5-I*v@}SES($PNug5Ti6b@!WgGk z_*%kPdycLW#$+0`ZqzQSj68pk0+ws$EPcIp4G8%g6z$3tkpxP@-qF#n(tEu=lpcPA z+y_5gr96ZL?2YSzXgo6S^XS1)*b@r$^?72EWXcoP4w*9>-i{#WH&(!oiKKz}J1OuT!Ad>P#{PPh{C>21n2Xx)z?@NZ}!ztabhx%4l zTe0<0Sb5ukwQ*_B|1Y5@)%?GV=Z&8K{gGI&KhnMm@P5z#l;hO&YD<~~WH=?d28q5g zvTYG^m$ELu&T_7CJqyqssZG6iGTc5luBQyItec(ES?KJcx~n+p~$Q+vUJMGi|C%dPr< zxxz_kv;txGv0GPRsXNWDA-!D1wNtRK6|f%&^mLP=(%7s|e6N7ky|Wr!_}j&cwbqrJ zmq_juV~M!-MNp;U_p;RL#!uucjrZ%#XLVzItbX)p|NZr==f8OThOy88>Y435`j5V& zGExz1+!^JOmHyu?;I91t$ZTun{xz39;O5HJ53Bdnr8RiTPr8vLaZmj`ypYG-!{sm< zKNiQRhq+p2{qwB;YW!qP!)F2IBsE`a+Ij5g7{cEm)_4IewtwXg5ccT=Rwm__8Ms!; z*`F(>^eXZc_bJ3UU@rOH3r}<<{oysQKqc{|v`V`2)VP%@IixaPblvjhF!l+F$uYVF7!9EdMrOby-yqO5R}n7O$AL3Mz4f;j(rw$72mWB8JYQN)Kwvgv|%+Q{Kj zGIEpn5=eYOU-Ma5eCa}byyQR~>eDzIU7NIbs+1iw()vie7-vOx_cN~gatYtq4;YF` syXWel_61REdHFVOTufU%-GgVGkpet701c%)?X`AB2)RI&sI5r+A5GSoA^-pY literal 0 HcmV?d00001 diff --git a/COVID-19/Visualization/Project/China.html b/COVID-19/Visualization/Project/China.html new file mode 100644 index 0000000..a9ee0b1 --- /dev/null +++ b/COVID-19/Visualization/Project/China.html @@ -0,0 +1,267 @@ + + + + + Awesome-pyecharts + + + + + +
+ + + diff --git a/COVID-19/Visualization/Project/Visualization.py b/COVID-19/Visualization/Project/Visualization.py new file mode 100644 index 0000000..6a99791 --- /dev/null +++ b/COVID-19/Visualization/Project/Visualization.py @@ -0,0 +1,193 @@ +import pandas as pd +import matplotlib.pyplot as plt +import matplotlib.dates as mdates +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 + +#打开数据文件 +dataset = pd.read_csv('E:\dase intro\COVID-19Analysis\COVID-19\covid-19-all.csv') + +#数据预处理 +def parse_ymd(s): + year_s, mon_s, day_s = s.split('-') + return datetime.datetime(int(year_s), int(mon_s), int(day_s)).strftime("%Y-%m-%d") + +dataset = dataset.fillna(0) + +dataset['Date'] = pd.to_datetime(dataset['Date']) + +#对China\US数据进行可视化操作 +China = dataset[dataset['Country/Region'] == 'China'].reset_index(drop=True) +US = dataset[dataset['Country/Region'] == 'US'].reset_index(drop=True) + +#计算中\美每日治愈率/确诊人数/治愈人数(分月份显示) +dfChinaJan = China[China['Date'].dt.month == 1] +dfChinaFeb = China[China['Date'].dt.month == 2] +dfChinaMar = China[China['Date'].dt.month == 3] +dfChinaApr = China[China['Date'].dt.month == 4] +dfChinaMay = China[China['Date'].dt.month == 5] +dfChinaJun = China[China['Date'].dt.month == 6] +dfChinaJul = China[China['Date'].dt.month == 7] +dfChinaAug = China[China['Date'].dt.month == 8] +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] +dfUSApr = US[US['Date'].dt.month == 4] +dfUSMay = US[US['Date'].dt.month == 5] +dfUSJun = US[US['Date'].dt.month == 6] +dfUSJul = US[US['Date'].dt.month == 7] +dfUSAug = US[US['Date'].dt.month == 8] +dfUSSept = US[US['Date'].dt.month == 9] +dfUSOct = US[US['Date'].dt.month == 10] +dfUSNov = US[US['Date'].dt.month == 11] +dfUSDec = US[US['Date'].dt.month == 12] + +confirmedChina = [dfChinaJan['Confirmed'].sum(),dfChinaFeb['Confirmed'].sum(),dfChinaMar['Confirmed'].sum(),dfChinaApr['Confirmed'].sum(), + dfChinaMay['Confirmed'].sum(),dfChinaJun['Confirmed'].sum(),dfChinaJul['Confirmed'].sum(),dfChinaAug['Confirmed'].sum(), + dfChinaSept['Confirmed'].sum(),dfChinaOct['Confirmed'].sum(),dfChinaNov['Confirmed'].sum(),dfChinaDec['Confirmed'].sum()] +recoveredChina = [dfChinaJan['Recovered'].sum(),dfChinaFeb['Recovered'].sum(),dfChinaMar['Recovered'].sum(),dfChinaApr['Recovered'].sum(), + 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()] +recoveredUS = [dfUSJan['Recovered'].sum(),dfUSFeb['Recovered'].sum(),dfUSMar['Recovered'].sum(),dfUSApr['Recovered'].sum(), + dfUSMay['Recovered'].sum(),dfUSJun['Recovered'].sum(),dfUSJul['Recovered'].sum(),dfUSAug['Recovered'].sum(), + dfUSSept['Recovered'].sum(),dfUSOct['Recovered'].sum(),dfUSNov['Recovered'].sum(),dfUSDec['Recovered'].sum()] +recoverPossUS = [] + +for i in range(len(confirmedChina)): + recoverPossChina.append(recoveredChina[i] / confirmedChina[i]) + recoverPossUS.append(recoveredUS[i] / confirmedUS[i]) + +#x轴为日期(月份) +date = pd.date_range(start='2020-01', periods=12, freq="m").strftime('%m') + +fig = plt.figure() + +#中国 +ax1 = fig.add_subplot(221) +ax1.set_title("Recovered/Confirmed/Recovery Possibility(month) of China",verticalalignment="bottom",fontsize="13") +data1 = ax1.plot(date,confirmedChina,color="red",linewidth="1.7",label="confirmed") +data2 = ax1.plot(date,recoveredChina,color="lime",linewidth="1.7",label="recovered") +ax1.set_ylabel('recovered/confirmed') +ax2 = ax1.twinx() +ax2.set_ylabel('recovery possibility') +data3 = ax2.plot(date,recoverPossChina,color="blue",linestyle="--",linewidth="1.0",label="recovery possibility") +datasChina = data1 + data2 + data3 +labsChina = [d.get_label() for d in datasChina] +ax1.legend(datasChina, labsChina, loc="lower right") + +#美国 +ax3 = fig.add_subplot(222) +ax3.set_title("Recovered/Confirmed/Recovery Possibility(month) of US",verticalalignment="bottom",fontsize="13") +data3 = ax3.plot(date,confirmedUS,color="red",linewidth="1.7",label="confirmed") +data4 = ax3.plot(date,recoveredUS,color="lime",linewidth="1.7",label="recovered") +ax3.set_ylabel('recovered/confirmed') +ax4 = ax3.twinx() +ax4.set_ylabel('recovery possibility') +data5 = ax4.plot(date,recoverPossUS,color="blue",linestyle="--",linewidth="1.0",label="recovery possibility") +datasUS = data3 + data4 + data5 +labsUS = [d.get_label() for d in datasUS] +ax3.legend(datasUS, labsUS, loc="upper left") + +#中国各省数据 +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') +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') +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) + +#中国省份(bottom 12) +dataChina.sort_values('Confirmed', inplace=True) +xData = [] +yConfirmed = [] +yRecovered = [] +for i in range(12): + 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") +barWidth = 0.25 +r1 = np.arange(12) +r2 = [x + barWidth for x in r1] +ax5.bar(r1, yConfirmed, color='#FF0088', width=barWidth, edgecolor='white', label='Confirmed') +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() + +#中国疫情图 +ChinaConfirmed = [] +ChinaProvince = [] +worldConfirmed = [] +provinceNameMap = {'Tibet':'西藏', 'Qinghai':'青海', 'Macau':'澳门', 'Ningxia':'宁夏', 'Jilin':'吉林', 'Guizhou':'贵州', + 'Gansu':'甘肃', 'Hainan':'海南', 'Shanxi':'山西', 'Yunnan':'云南', 'Liaoning':'辽宁', 'Tianjin':'天津', + 'Inner Mongolia':'内蒙古', 'Guangxi':'广西', 'Shaanxi':'陕西', 'Hebei':'河北', 'Fujian':'福建', 'Xinjiang':'新疆', + 'Chongqing':'重庆', 'Sichuan':'四川', 'Jiangsu':'江苏', 'Beijing':'北京', 'Shanghai':'上海', 'Shandong':'山东', + 'Heilongjiang':'黑龙江', 'Jiangxi':'江西', 'Anhui':'安徽', 'Hunan':'湖南', 'Zhejiang':'浙江', 'Henan':'河南', + 'Guangdong':'广东', 'Hong Kong':'香港', 'Hubei':'湖北'} + +for i in range(33): + ChinaConfirmed.append(dataChina['Confirmed'][i]) + ChinaProvince.append(provinceNameMap[dataChina.index[i]]) + + +map_China = Map() +map_China.set_global_opts(title_opts=options.TitleOpts(title="中国(大陆)疫情图-总确诊人数"), + legend_opts=options.LegendOpts(is_show=False), + visualmap_opts=options.VisualMapOpts(max_=200000)) +map_China.add("",[list(z) for z in zip(ChinaProvince, ChinaConfirmed)], maptype='china') +map_China.render("China.html") + +#世界疫情图 +worldConfirmed = [] +worldName = [] +for i in range(dataWorld.shape[0]): + worldConfirmed.append(dataWorld['Confirmed'][i]) + if dataWorld.index[i] == 'US': + worldName.append('United States') + else: + worldName.append(dataWorld.index[i]) + +map_world = Map() +map_world.set_global_opts(title_opts=options.TitleOpts(title="世界疫情图-总确诊人数"), + legend_opts=options.LegendOpts(is_show=True), + visualmap_opts=options.VisualMapOpts(min_=10000,max_=80000000)) +map_world.add("",[list(z) for z in zip(worldName, worldConfirmed)], maptype='world') +map_world.render("world.html") + + diff --git a/COVID-19/Visualization/Project/Visualization.pyproj b/COVID-19/Visualization/Project/Visualization.pyproj new file mode 100644 index 0000000..02f44d7 --- /dev/null +++ b/COVID-19/Visualization/Project/Visualization.pyproj @@ -0,0 +1,40 @@ + + + Debug + 2.0 + 7bbaccfa-5595-4614-93c7-7e130a65b9aa + + + Visualization.py + + + . + . + Visualization + Project + CondaEnv|CondaEnv|env + + + true + false + + + true + false + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/COVID-19/Visualization/Project/world.html b/COVID-19/Visualization/Project/world.html new file mode 100644 index 0000000..c2d7e9d --- /dev/null +++ b/COVID-19/Visualization/Project/world.html @@ -0,0 +1,1007 @@ + + + + + Awesome-pyecharts + + + + + +
+ + + diff --git a/COVID-19/Visualization/Visualization.sln b/COVID-19/Visualization/Visualization.sln new file mode 100644 index 0000000..ddde8dc --- /dev/null +++ b/COVID-19/Visualization/Visualization.sln @@ -0,0 +1,23 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30717.126 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "Visualization", "Project\Visualization.pyproj", "{7BBACCFA-5595-4614-93C7-7E130A65B9AA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7BBACCFA-5595-4614-93C7-7E130A65B9AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7BBACCFA-5595-4614-93C7-7E130A65B9AA}.Release|Any CPU.ActiveCfg = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0D9731B0-0B1C-46C6-A604-021D09B35A11} + EndGlobalSection +EndGlobal