import pandas as pd from pyecharts.charts import Pie from pyecharts import options as opts data = pd.read_csv("最新数据.csv") d2 = data[['职位名称','公司规模']] d3 = d2.groupby('公司规模').count() gm_data = [i for i in zip(d3.index.tolist(),d3['职位名称'].tolist())] pie = Pie()\ .add("公司规模饼图",gm_data,radius=[0,"50%"], label_opts=opts.LabelOpts(formatter='{b}:{d}%'))\ .set_global_opts( title_opts=opts.TitleOpts('各种公司规模所占比例',pos_left="35%",pos_top="3%", title_textstyle_opts=opts.TextStyleOpts(font_size=25)), legend_opts=opts.LegendOpts(orient="vertical",pos_left='10%',pos_top='18%') )\ .set_colors(['#9fe080','#5c7bd9','#ffdc60','#ff7070','#7ed3fc','#8470FF']) pie.render("公司规模饼图.html")