首页 > 解决方案 > 数据框散点图上的关键错误

问题描述

我正在尝试从 df 打印纬度和经度值的散点图。运行时:

info.plot.scatter(x=info['latitude'], y=info['longitude'])

我收到以下关键错误

KeyError: "None of [Float64Index([        34.6951242,         34.6951242,         34.6951242,\n                      34.6951242,         35.6580681,         35.6580681,\n                      35.6580681,         35.6580681,         35.6580681,\n                      35.6580681,\n              ...\n                      35.7511648,         35.7511648,         35.6940027,\n                      35.6940027,         35.6617773,         35.6617773,\n                      35.6617773,         35.6617773, 43.055460100000005,\n              43.055460100000005],\n             dtype='float64', length=829)] are in the [columns]"

当我打印尾部时,df 看起来是正确的。谁能弄清楚发生了什么?

标签: pythonpandasdataframejupyter-notebook

解决方案


放弃info内部scatter

info.plot.scatter(x='latitude', y='longitude')

或使用plt.scatter

plt.scatter(x=info['latitude'], y=info['longitude'])

推荐阅读