【数据分析可视化】病毒传播-随笔

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

# 基础
import numpy as np
import pandas as pd
from pandas import DataFrame, Series
from datetime import datetime
import json
import warnings
warnings.filterwarnings('ignore')# 忽略python运行过程中的警告

# 可视化
import matplotlib.pyplot as plt
import seaborn as sns
from wordcloud import WordCloud,STOPWORDS,ImageColorGenerator # 导入词云包
%matplotlib inline
url ='/Users/bennyrhys/Desktop/数据分析可视化/homework/2020冠状肺炎统计.xlsx'
df = pd.read_excel(url, index_col='日期')
df.head()
累计确诊 疑似 新增疑似 死亡 治愈 现有确诊 境外输入 现有境外输入确诊
日期
2020-01-11 41.0 0.0 NaN 1.0 2.0 38.0 NaN NaN
2020-01-12 41.0 0.0 NaN 1.0 7.0 33.0 NaN NaN
2020-01-13 41.0 0.0 NaN 1.0 7.0 33.0 NaN NaN
2020-01-14 41.0 0.0 NaN 1.0 7.0 33.0 NaN NaN
2020-01-15 41.0 0.0 NaN 2.0 12.0 27.0 NaN NaN
df['新增疑似'].isnull()
日期
2020-01-11     True
2020-01-12     True
2020-01-13     True
2020-01-14     True
2020-01-15     True
              ...  
2020-04-27    False
2020-04-28    False
2020-04-29    False
2020-04-30     True
2020-05-01     True
Name: 新增疑似, Length: 112, dtype: bool
df.fillna(0)
累计确诊 疑似 新增疑似 死亡 治愈 现有确诊 境外输入 现有境外输入确诊
日期
2020-01-11 41.0 0.0 0.0 1.0 2.0 38.0 0.0 0.0
2020-01-12 41.0 0.0 0.0 1.0 7.0 33.0 0.0 0.0
2020-01-13 41.0 0.0 0.0 1.0 7.0 33.0 0.0 0.0
2020-01-14 41.0 0.0 0.0 1.0 7.0 33.0 0.0 0.0
2020-01-15 41.0 0.0 0.0 2.0 12.0 27.0 0.0 0.0
... ... ... ... ... ... ... ... ...
2020-04-27 82836.0 9.0 1.0 4633.0 77555.0 648.0 1639.0 552.0
2020-04-28 82858.0 10.0 2.0 4633.0 77578.0 647.0 1660.0 553.0
2020-04-29 82862.0 10.0 3.0 4633.0 77610.0 619.0 1664.0 525.0
2020-04-30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
2020-05-01 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0

112 rows × 8 columns

# 直方图
plt.hist(df['新增疑似'])
(array([66.,  3.,  6.,  3.,  2.,  1.,  3.,  6.,  1.,  6.]),
 array([   0. ,  532.8, 1065.6, 1598.4, 2131.2, 2664. , 3196.8, 3729.6,
        4262.4, 4795.2, 5328. ]),
 <a list of 10 Patch objects>)

在这里插入图片描述

# 密度图 Series 的方法直接画.plot
df['新增疑似'].plot(kind='kde')
<matplotlib.axes._subplots.AxesSubplot at 0x1a27b80510>

在这里插入图片描述

# 直方图,密度图.distplot()
# 参数 数据,分块,是否直方图,是否密度图,rug分布情况
sns.distplot(df['新增疑似'], bins=20, hist=True, kde=True, rug=True)
<matplotlib.axes._subplots.AxesSubplot at 0x1a29f5a410>

在这里插入图片描述

# 密度图
# 参数 数据,颜色填充, 颜色
sns.kdeplot(df['新增疑似'], shade=True, color='r')
<matplotlib.axes._subplots.AxesSubplot at 0x1a2aee4150>

在这里插入图片描述

sns.rugplot(df['新增疑似'])
<matplotlib.axes._subplots.AxesSubplot at 0x1a2b140490>

在这里插入图片描述

plt.plot(df['新增疑似'])
[<matplotlib.lines.Line2D at 0x1a2aea7290>]

在这里插入图片描述

# 热力图(新增疑似)
sns.heatmap(df)
<matplotlib.axes._subplots.AxesSubplot at 0x1a2aed6cd0>

在这里插入图片描述

# df普通线性
df.plot()
<matplotlib.axes._subplots.AxesSubplot at 0x1a2a7e5550>

在这里插入图片描述

from pyecharts.faker import Faker  # 绘图导入数据需要
from pyecharts import options as opts  # 绘图选项
from pyecharts.charts import Map  # 绘图需要
import csv  # 读取中国各省gdp增长数据

猜你喜欢

转载自blog.csdn.net/weixin_43469680/article/details/105988371
今日推荐