import pandas as pd
import matplotlib.pyplot as plt
df1=df[df["城市"]==”杭州市”]
df1_count=df1.groupby("院校类型"(参考))["院校名称"].count()
plt.rc("font",**{"family":"SimHei"})
plt.figure()
1⃣️plt.pie(df1_count.values,labels=df1_count.index,autopct="%1.2f%%")
plt.title("2020年杭州市类型院校分布情况")
plt.show()
df1_count.values 即每个扇形的占比的序列或数组为df1_count的values项
labels=df1_count.index为每个扇形提供标签的字符串序列为df1_count的index项
autopct="%1.2f%% 格式化标签为保留两位小数的百分比形式显示
引入pandas 处理数据,根据院校类型分组统计,最后画一张饼图出来