大家好,我是 【Python当打之年(点击跳转)】
高考刚刚落幕,本期利用 python 分析一下我国高校及专业数据,看看:
希望对大家有所帮助,如有疑问或者需要改进的地方可以联系小编。
import pandas as pd
from pyecharts.charts import Bar
from pyecharts.charts import Map
from pyecharts.charts import Pie
from pyecharts.charts import WordCloud
from pyecharts import options as opts
df_school = pd.read_csv('高校.csv',encoding='gbk')
df_professional = pd.read_csv('专业.csv',encoding='gbk')
def get_map1():
m1 = (
Map()
.add('',
[list(z) for z in zip(df_school_count.index.tolist(), df_school_count.values.tolist())],
maptype='china',
is_map_symbol_show=False,
label_opts=opts.LabelOpts(is_show=False,color='red')
)
.set_global_opts(
visualmap_opts=opts.VisualMapOpts(
is_show=True,
max_ = 200,
pos_top='60%',
pos_left='10%',
),
tooltip_opts=opts.TooltipOpts(formatter='{b}:{c}'),
title_opts=opts.TitleOpts(title='1-全国高校分布地图',subtitle='-- 制图@公众号:Python当打之年 --',pos_top='2%',pos_left="2%",
title_textstyle_opts=opts.TextStyleOpts(color='#fff200',font_size=20))
)
)
def get_pie1():
pie1 = (
Pie()
.add(
"",
[list(z) for z in zip(df_school_count.index.tolist(), df_school_count.values.tolist())],
radius=["30%", "60%"],
label_opts=opts.LabelOpts(formatter="{b}: {c}")
)
.set_global_opts(
title_opts=opts.TitleOpts(title='3-本科/专科占比',subtitle='-- 制图@公众号:Python当打之年 --',pos_top='2%',pos_left="2%",
title_textstyle_opts=opts.TextStyleOpts(color='#fff200',font_size=20)),
legend_opts=opts.LegendOpts( pos_top="5%"),
)
)
def get_bar1():
bar1 = (
Bar()
.add_xaxis(df_school_count.index.tolist())
.add_yaxis("",df_school_count.values.tolist(),label_opts=opts.LabelOpts(position='right'))
.reversal_axis()
.set_global_opts(
visualmap_opts=opts.VisualMapOpts(
is_show=False,
max_ = 1000,
dimension=0,
range_color=range_color
),
title_opts=opts.TitleOpts(title='5-办学类别排行',subtitle='-- 制图@公众号:Python当打之年 --',pos_top='2%',pos_left="2%",
title_textstyle_opts=opts.TextStyleOpts(color='#fff200',font_size=20))
)
)
def get_bar2():
bar2 = (
Bar()
.add_xaxis(df_school_tmp_count.index.tolist())
.add_yaxis("",df_school_tmp_count.values.tolist())
.set_global_opts(
xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=30)),
visualmap_opts=opts.VisualMapOpts(
is_show=False,
max_ = 20,
dimension=1,
range_color=range_color
),
title_opts=opts.TitleOpts(title='6-985/211/双一流主要分布城市Top20',pos_top='2%',pos_left="2%",
title_textstyle_opts=opts.TextStyleOpts(color='#fff200',font_size=20))
)
)
def get_wordcloud():
wordcloud = (
WordCloud()
.add("",
words,
word_size_range=[5, 50]
)
.set_global_opts(
legend_opts=opts.LegendOpts(is_show=False),
title_opts=opts.TitleOpts(title='10-国家特色专业词云',pos_top='2%',pos_left="2%",
title_textstyle_opts=opts.TextStyleOpts(color='#fff200',font_size=20)),
)
)
点击跳转:【全部可视化项目源码+数据】
以上就是本期为大家整理的全部内容了,赶快练习起来吧,原创不易,喜欢的朋友可以点赞、收藏也可以分享(注明出处)让更多人知道。