【发布时间】:2019-03-15 02:34:03
【问题描述】:
我正在尝试从 pandas 数据框创建散点图,但我不想使用 matplotlib plt。以下是脚本
df:
group people value
1 5 100
2 2 90
1 10 80
2 20 40
1 7 10
我想在 x 轴上创建一个带有索引的散点图,只使用 pandas datframe
df.plot.scatter(x = df.index, y = df.value)
它给了我一个错误
Int64Index([0, 1, 2, 3, 4], dtype='int64') not in index
我不想用
plt.scatter(x = df.index, y = df.value)
如何使用 pandas 数据框执行此图
【问题讨论】:
-
试试 df.plot.scatter(x = df.index.tolist(), y = df.value)
-
它不适合我
标签: python pandas matplotlib plot