我正在尝试从 CSV 文件制作饼图,但它并没有达到预期的效果,因为我希望将国家数量的比较作为输出,代码如下:饼图的输出:
WHO Region Country/Region (Count All)
Africa 48
Americas 35
Eastern Mediterranean 22
Europe 56
South-East Asia 10
Western Pacific 16
df2 = pd.read_csv('PC.csv')
df2.head()
df2 = df.rename(columns={"WHO Region":"WHO_Regions","Country/Region (Count
All)":"Countries"})
df2.head(6)
data_pie=df2['WHO_Regions'].value_counts().rename_axis('WHO_Regions').reset_index(name='Countries')
plt.figure(figsize=(10,10))
plt.pie(data_pie.Countries, labels=data_pie.WHO_Regions, startangle=45,autopct='%1.1f%%')
plt.title('Count of Active cases')
plt.show()
