[英]Is there any way I can fix the error string indices must be integers?
I tried to make graphs for my csv dataset in Jupyter Notebook, using this line of code:我尝试使用以下代码行在 Jupyter Notebook 中为我的 csv 数据集制作图表:
bank['marital'].value_counts().plot(kind='pie',autopct='%.2f')
plt.show()
However, the system return, "string indices must be integers".但是,系统返回“字符串索引必须是整数”。
I have tried to use many different methods like changing the string to a number,... but nothing really worked我尝试使用许多不同的方法,例如将字符串更改为数字,......但没有任何效果
I tried to reproduce it and it worked fine.我试图重现它并且它工作正常。 So it's not something wrong with the code itself.所以这不是代码本身的问题。 I suggest experimenting with:我建议尝试:
Attaching my results:附上我的结果:
[input.csv]
name,smth
Maria,12
Anton,2
Maria,3
...
df = pd.read_csv('input.csv')
df['name'].value_counts().plot(kind='pie',autopct='%.2f')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.