我想为下面的数据集使用matplotlib绘制图表。

但我发现了这个错误.
None of [Index(['roberta_neg', 'roberta_neu', 'roberta_pos'], dtype='object')] are in the [columns]. 我使用的代码是:
df.plot(x="Ratings", y=["roberta_neg", "roberta_neu","roberta_pos"], kind="bar")发布于 2022-09-06 06:42:09
我相信您正在加载的数据有问题。当列名之间存在不匹配时(就像列名之前/之后的空格),会出现所显示的错误。当我运行代码的时候,它运行的很好。然而,当我添加一个空格时,我能够复制这个。所以,在你画数字之前加上这一行.
df.columns = df.columns.str.replace(' ', '')
df.plot(x="Ratings", y=["roberta_neg", "roberta_neu","roberta_pos"], kind="bar")绘图创建了

https://stackoverflow.com/questions/73617443
复制相似问题