Python疫情数据可视化分析+数据预测(pandas+pyecharts+statsmo。。。

阅读: 评论:0

Python疫情数据可视化分析+数据预测(pandas+pyecharts+statsmo。。。
1、MySQL数据库获取数据
此处的原始数据表是全国各省的实时数据集,现在只获取江苏省份的数据
engine = create_engine(mysq_conn)# 具体内容以⾃⼰上就可以为准
select_data ="select * from table_data where area='江苏'order by local_time desc"
df = pd.read_sql(sql=select_data, con=engine)
df.head()
2、转存数据集⾄本地csv,以免每次都要从数据库读取数据
3、⽇期字符串字段,数据清洗
#转化获取年-⽉-⽇
new_df['⽇期']= new_df['local_time'].dt.year.map(str)+'-'+new_df['local_time'].dt.month.map(str)+'-'+new_df['local_time'].dt.day.map(str)
4、数据可视化
from pyecharts import options as opts
from pyecharts.charts import Bar,Line,Pie,WordCloud,EffectScatter
from pyecharts.charts import PictorialBar
from pyecharts.globals import SymbolType
from pyecharts.globals import ThemeType
Line(init_opts=opts.InitOpts(theme=ThemeType.MACARONS))
.add_xaxis(x_label)
.add_yaxis(
is_smooth=True,
symbol="emptyCircle",
is_symbol_show=False,
color="#6e9ef1",
y_axis=y_data,
label_opts=opts.LabelOpts(is_show=False),
)
.set_series_opts(
label_opts=opts.LabelOpts(
is_show=False,
position="inside",
formatter="{c}",
)
)
.
set_global_opts(
title_opts=opts.TitleOpts(title="江苏省⽇新增确诊趋势图"),
tooltip_opts=opts.TooltipOpts(is_show=True,axis_pointer_type="cross",trigger="axis"),        xaxis_opts=opts.AxisOpts(
name_rotate=60,axislabel_opts={"rotate":45},
axispointer_opts=opts.AxisPointerOpts(
is_show=True,
),
),
)
)
Line()
.add_xaxis(xaxis_data=x_label)
.add_yaxis(
series_name="最⾼新增城市",
is_smooth=True,
symbol="emptyCircle",
is_symbol_show=False,
color="#d14a61",
y_axis=y_data,
)
西安周边2小时自驾
.add_yaxis(
series_name="全省新增",
is_smooth=True,
symbol="emptyCircle",
is_symbol_show=False,
color="#6e9ef1",
y_axis=y_data2,
)
.set_global_opts(
title_opts=opts.TitleOpts(title="江苏省⽇新增确诊突然增原因"),
legend_opts=opts.LegendOpts(),
xaxis_opts=opts.AxisOpts(
type_="category",
axistick_opts=opts.AxisTickOpts(is_align_with_label=True),
axisline_opts=opts.AxisLineOpts(
is_on_zero=False, linestyle_opts=opts.LineStyleOpts(color="#d14a61") ),
axispointer_opts=opts.AxisPointerOpts(
is_show=True, label=opts.LabelOpts(formatter=JsCode(js_formatter)) ),
),
yaxis_opts=opts.AxisOpts(
type_="value",
splitline_opts=opts.SplitLineOpts(
is_show=True, linestyle_opts=opts.LineStyleOpts(opacity=1) ),
),
)
)
邯郸旅游景点大全排名
def line_charts()->Line:
line1 =(
三亚房价一夜全跌了Line(init_opts=opts.InitOpts(width='1000px',height='500px'))# ⽰例对象.add_xaxis(x_label)# x轴数据
.
add_yaxis(
"治愈率",# 图例名称
is_smooth=True,
is_symbol_show=False,
color="#6e9ef1",
y_axis=y_label,# y轴数据
label_opts=opts.LabelOpts(is_show=False),
linestyle_opts=opts.LineStyleOpts(width=2),
yaxis_index=0,
)
# 全局配置:标题/副标题
.
set_global_opts(
镜泊湖旅游攻略自助游title_opts=opts.TitleOpts(title="全国治愈率/死亡率趋势图"),# 标题
迪拜是发达国家吗xaxis_opts=opts.AxisOpts(
name_rotate=60,axislabel_opts={"rotate":45},
),
yaxis_opts=opts.AxisOpts(
name='治愈率(%)',
min_=70,
max_=100,
interval=10,
axislabel_opts=opts.LabelOpts(formatter='{value}%')
)
,
toolbox_opts=opts.ToolboxOpts(# ⼯具栏
is_show =True,
pos_top="top",
pos_left="right",
feature={
"saveAsImage":{},
"dataZoom":{"yAxisIndex":"none"},
"restore":{},
日照海边民宿排行"magicType":{"show":True,"type":["line","bar"]},
"dataView":{}
},
)
)
# bar 拓展
# bar 拓展
.extend_axis(
yaxis=opts.AxisOpts(
name='死亡率(%)',
type_='value',# 类型
min_=3,
max_=6,
interval=1,
)
)
)
return line1
def line2_charts()->Line():
line1=(
Line()
.add_xaxis(x_label)
.add_yaxis(
'死亡率',
y_axis=y_label1,
is_smooth=True,# 设置线为平滑的
symbol="emptyCircle",# 悬浮数据样式            is_symbol_show=False,# 显⽰数据
color="#6e9ef1",
)
)
return line1
line1=line_charts()
line2=line2_charts()
line1.overlap(line2).render_notebook()
bar =(
Line()
.add_xaxis(xaxis_data=x_data)
.add_yaxis(
series_name="累计确诊",
y_axis=evaporation_capacity,
yaxis_index=0,
color=colors[1],
label_opts=opts.LabelOpts(is_show=True),        is_smooth=True,
symbol="emptyCircle",

本文发布于:2023-07-12 01:32:47,感谢您对本站的认可!

本文链接:http://www.035400.com/whly/2/524222.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:数据   新增   确诊   江苏省   全国   可视化   趋势
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2024-2030 Comsenz Inc.Powered by © 文化旅游网 滇ICP备2022007236号-403 联系QQ:1103060800网站地图