Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
735 views
in Technique[技术] by (71.8m points)

raise KeyError(key) Python

I get this error when executing my code do you have an idea how to fix it? here is the image and the code of the first lines of my csv file, the file is too big to display it entirely. the code is complete. i try to display the points on a map with geoplotlib

enter image description here

import geoplotlib
import csv
import pandas as pd

data = pd.read_csv('E:Projet de Memoir sur les tics/humdataAL.csv')
geoplotlib.dot(data)
geoplotlib.show()

It returns the following error:

Traceback (most recent call last):
  File "C:Users
samaPycharmProjectspythonProjectamara_projectvenvlibsite-packagesgeoplotlib\__init__.py", line 32, in _runapp
    app.start()
  File "C:Users
samaPycharmProjectspythonProjectamara_projectvenvlibsite-packagesgeoplotlibcore.py", line 364, in start
    self.proj.fit(BoundingBox.from_bboxes([l.bbox() for l in self.geoplotlib_config.layers]),
  File "C:Users
samaPycharmProjectspythonProjectamara_projectvenvlibsite-packagesgeoplotlibcore.py", line 364, in <listcomp>
    self.proj.fit(BoundingBox.from_bboxes([l.bbox() for l in self.geoplotlib_config.layers]),
  File "C:Users
samaPycharmProjectspythonProjectamara_projectvenvlibsite-packagesgeoplotliblayers.py", line 159, in bbox
    return BoundingBox.from_points(lons=self.data['lon'], lats=self.data['lat'])
  File "C:Users
samaPycharmProjectspythonProjectamara_projectvenvlibsite-packagespandascoreframe.py", line 3024, in __getitem__
    indexer = self.columns.get_loc(key)
  File "C:Users
samaPycharmProjectspythonProjectamara_projectvenvlibsite-packagespandascoreindexesase.py", line 3082, in get_loc
    raise KeyError(key) from err
KeyError: 'lon'
question from:https://stackoverflow.com/questions/65863922/raise-keyerrorkey-python

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...