【发布时间】:2021-05-27 23:30:37
【问题描述】:
大家好:) 我是 python 的新手,我被分配了这个我发现不可能弄清楚的任务。我希望这里有人可以帮助我。 我收到了 3 个 excel 文件,其中包含有关欧洲周围空气污染水平的信息(我无法共享这些文件) 我需要在谷歌地图上绘制特定国家(马耳他、意大利、波兰、德国和法国)的坐标和空气污染水平。这是我正在使用的代码:
import gmplot #importing of gmplot
import pandas as pd #importing of pandas
df = pd.read_excel (data_path_eu_2016) #i know this is meant to be a path, however i saved the path
in a variable earlieer on in my code so im using the variable name here so that the user will only
need to insert their path once when using my code
df_lat =df['Latitude'] #picking the latitudes
df_lon =df['Longitude'] #picking of the longitude
df_Country = df['Country'] #i'm including these variables as my assignment instructions says to use
them though im not sure how to incorporate them in this googlemaps plot
df_City = df['City']
df_AirPollutionLevel = df['AirPollutionLevel']
df_Altitude = df['Altitude']
gmap = gmplot.GoogleMapPlotter(48.925278, 2.356667, 5) #chose a random set of coordinates from one of
the countries i need to plot data for
gmap.scatter(df_lat[:1000], df_lon[:1000], 'red', size = 10) #Scattering of the coordinates using the
lat and long list
gmap.draw(r"C:\Users\julia\OneDrive\Documents\python assignment\gmplot_Map.html") #the location where
the HTML file is to be saved
但是我得到这个错误: 回溯错误:df_lat =df['Latitude'] #picking the latitudes KeyError:“纬度”
我的 excel 文件中存在列名“纬度”,所以我不确定错误是什么?
我将非常感谢任何帮助!
【问题讨论】:
标签: python pandas pycharm gmplot