数据为5列乘46589行,并包含全名,名字,性别(字母M或F),纬度和经度。
data = pd.read_csv('genderizer.csv', names=['full_name', 'first_name', 'gender', 'latitude', 'longitude'])
n = folium.Map([20, 0], tiles= 'Mapbox Bright', zoom_start=2)
for i in range(len(data)):
long = float(data.iloc[i]['longitude'])
lat = float(data.iloc[i]['latitude'])
popup = data.iloc[i]['gender']
folium.CircleMarker([lat, long], radius=15, popup=popup, fill_color="#3db7e4").add_to(n)
long = int(long)
lat = int(lat)
data = [lat][long]
HeatMap(data).add_to(n)
我收到的错误消息是:
IndexError Traceback (most recent call last)
<ipython-input-11-03b638ce9e81> in <module>()
8 long = int(long)
9 lat = int(lat)
---> 10 data = [lat][long]
11 HeatMap(data).add_to(n)
IndexError: list index out of range
我不知道此代码是否是解决此问题的正确方法,请帮忙。