python - 数据框散点图上的关键错误
问题描述
我正在尝试从 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 看起来是正确的。谁能弄清楚发生了什么?
解决方案
放弃info
内部scatter
:
info.plot.scatter(x='latitude', y='longitude')
或使用plt.scatter
:
plt.scatter(x=info['latitude'], y=info['longitude'])
推荐阅读
- python - 将一个文件 Tkinter 条目分配给另一个文件 tkinter 条目
- react-native - 如何制作圆形倒计时/仪表以显示反应原生的剩余天数
- python - 使用 AutoSys 运行 python 脚本时出错
- terraform - 重用在terraform的父模块中声明和定义的变量
- python - 过滤python请求结果
- database - MongoDB/Mongoose:对同一集合中不同类型的文档使用不同的方案
- android - 如何在 Android 上的 Xamarin.forms 应用程序中呈现动态生成的地图图钉?
- c# - 自动更新 WinForms 应用程序(异步)
- c# - 如果 readalltext 找不到文件,请创建文件
- android - android 10 aosp 中哪里有 3 个点?