diff --git a/COVID-19/Project/.vs/Project/v16/.suo b/COVID-19/Project/.vs/Project/v16/.suo index 68e1f5b..f22d947 100644 Binary files a/COVID-19/Project/.vs/Project/v16/.suo and b/COVID-19/Project/.vs/Project/v16/.suo differ 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 @@ + + +