10年内,哪一年高考题目最难?
裸睡的猪
共 4951字,需浏览 10分钟
·
2021-05-29 07:38
作者 |鸟哥
来源 | python数据分析之禅
下面从3个角度进行分析
代码:
bar = (
Bar()
.add_xaxis(list(range(2010,2021)))
.add_yaxis(series_name="历年一本线排名", yaxis_data=eve_scores_line, yaxis_index=0, color=colors[0])
.set_series_opts(
label_opts=opts.LabelOpts(is_show=True),
markline_opts=opts.MarkLineOpts(
data=[
opts.MarkLineItem(type_="min", name="最小值"),
opts.MarkLineItem(type_="max", name="最大值"),
opts.MarkLineItem(type_="average", name="平均值"),
]
),
colors=Faker.rand_color()
)
.set_global_opts(
xaxis_opts=opts.AxisOpts(name="年份",axisline_opts=opts.AxisLineOpts(
linestyle_opts=opts.LineStyleOpts(color=colors[1]))),
yaxis_opts=opts.AxisOpts(
name="分数",
type_="value",
min_=400,
max_=600,
position="left",
axisline_opts=opts.AxisLineOpts(
linestyle_opts=opts.LineStyleOpts(color=colors[2])
),
axislabel_opts=opts.LabelOpts(formatter="{value}"),
axistick_opts=opts.AxisTickOpts(is_show=True),
splitline_opts=opts.SplitLineOpts(is_show=True),
),
tooltip_opts=opts.TooltipOpts(trigger="axis", axis_pointer_type="cross"),
)
.render("每年一本线.html")
)
for i in range(2010,2021): a=data[data['年份'].eq(i)] a=a[a['成绩'].ge(200)] a = a[a['成绩'].le(700)] sum_students = max(list(a['排名'])) dict={'200-300':0, '300-400':0, '400-500':0, '500-600':0, '600-700':0} for j in range(200,700,100): stmp = a[a['成绩'].ge(j)] stmp = stmp[stmp['成绩'].le(j+100)] renshu=int(list(stmp['排名'])[-1])-int(list(stmp['排名'])[0]) dict['{0}-{1}'.format(j,j+100)]=round(float(renshu/sum_students)*100,2) data_eve_years.append(dict)attr = Faker.choose()tl = Timeline()for i,j in zip(range(2010, 2021),data_eve_years): pie = ( Pie() .add( "", [list(z) for z in zip(list(j.keys()), [j[k] for k in list(j.keys())])], rosetype="radius", radius=["30%", "55%"], ) .set_global_opts(title_opts=opts.TitleOpts("{}年各分数段人数占比".format(i))) .set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}%")) ) tl.add(pie, "{}年".format(i))tl.render("timeline_pie.html")c = ( Line() .add_xaxis(xaxis_data=['{0}年'.format(i) for i in list(range(2010, 2021))]) .add_yaxis( series_name="历年600-700分人数占比情况", y_axis=[i['600-700'] for i in data_eve_years]) .set_global_opts( xaxis_opts=opts.AxisOpts(name="年份",axisline_opts=opts.AxisLineOpts( linestyle_opts=opts.LineStyleOpts(color='r'))), yaxis_opts=opts.AxisOpts( name="占比", type_="value", position="left", axislabel_opts=opts.LabelOpts(formatter="{value}%"), axistick_opts=opts.AxisTickOpts(is_show=True), splitline_opts=opts.SplitLineOpts(is_show=True), ), tooltip_opts=opts.TooltipOpts(trigger="axis", axis_pointer_type="cross"), ) .render("600-700占比折线图.html"))
分析角度3:平均分排名
代码:
c = (
Line()
['{0}年'.format(i) for i in list(range(2010,2021))]) =
.add_yaxis(
series_name="前1万名",
y_axis=result[0],
)
.add_yaxis(
series_name="前2万名",
y_axis=result[1],
)
.add_yaxis(
series_name="前3万名",
y_axis=result[2],
)
.add_yaxis(
series_name="前4万名",
y_axis=result[3],
)
.set_global_opts(
xaxis_opts=opts.AxisOpts(name="年份",axisline_opts=opts.AxisLineOpts(
linestyle_opts=opts.LineStyleOpts(color='r'))),
yaxis_opts=opts.AxisOpts(
name="分数",
type_="value",
min_=500,
max_=700,
position="left",
axislabel_opts=opts.LabelOpts(formatter="{value}"),
axistick_opts=opts.AxisTickOpts(is_show=True),
splitline_opts=opts.SplitLineOpts(is_show=True),
),
tooltip_opts=opts.TooltipOpts(trigger="axis", axis_pointer_type="cross"),
)
.render("折线图.html")
)
评论