【发布时间】:2022-01-26 02:25:38
【问题描述】:
当我尝试在 jupyter notebook 上运行此代码时,出现“类型错误:int object is not callable”,此代码的先前步骤如下: 1-我已将 matplotlib.pyplot 作为 plt 以及 pandas 作为 pd 导入 2- 将 x 定义为一系列字符串数据类型 3- 将 y 定义为数值数据类型 代码如下:
plt.figure(figsize=(9, 6))
x = data_used_cars["Brand"]
y = data_used_cars["Cars Listings"]
plt.bar(x=x, height=y)
plt.xticks(rotation=45)
plt.show()
数据集:
| Brand | Cars Listings |
|---|---|
| Audi | 419 |
| BMW | 636 |
| Mercedes-Benz | 820 |
| Mitsubishi | 306 |
| Renault | 438 |
| Toyota | 509 |
| Volkswagen | 875 |
希望我能找到解决办法
【问题讨论】:
-
代码调用正确。
x和y变量中的内容是什么?我认为问题出在某个地方。 -
x是字符串数据类型,y是"int64",x代表车种,y是频率,这个问题让我头疼,搞不清楚原因
-
我附上了一张显示使用的数据集的图片
标签: python matplotlib rotation data-analysis