【发布时间】:2015-05-30 12:26:42
【问题描述】:
我正在尝试散点图以下数据框:
mydf = pd.DataFrame({'x':[1,2,3,4,5,6,7,8,9],
'y':[9,8,7,6,5,4,3,2,1],
'z':np.random.randint(0,9, 9)},
index=["12:00", "1:00", "2:00", "3:00", "4:00",
"5:00", "6:00", "7:00", "8:00"])
x y z
12:00 1 9 1
1:00 2 8 1
2:00 3 7 7
3:00 4 6 7
4:00 5 5 4
5:00 6 4 2
6:00 7 3 2
7:00 8 2 8
8:00 9 1 8
我希望将时间“12:00, 1:00, ...”作为 x 轴,将 x,y,z 列作为 y 轴。
当我尝试通过 mydf.plot(kind="scatter") 使用 pandas 进行绘图时,我收到错误 ValueError: scatter requires and x and y column。我是否必须将我的数据框分解为适当的参数?我真正想做的是用 seaborn 绘制这个散点图。
【问题讨论】:
标签: python pandas dataframe seaborn