我该如何解决这个问题?基本上,我想根据地理信息创建推文地图。我收集的所有推文都在美国境内,并且还有地理信息。
Traceback (most recent call last):
File "tweet_map.py", line 19, in <module>
tweet_map.circle_marker(location=geo, radius=250)
AttributeError: 'Map' object has no attribute 'circle_marker'
以下是代码:
#create a map of tweets using Folium
import folium, pandas, ast
# get geo data only from rows with non-empty values
locations = pandas.read_csv('./usa_tweets.csv', usecols=[3]).dropna()
geos = []
for location in locations.values:
# add to geos array an evaluated python literal syntax of the data
geos.append(ast.literal_eval(location[0])['coordinates'])
# initialize and create map
tweet_map = folium.Map(location=[52.8, -2], tiles='Mapbox Bright', zoom_start=7)
# add markers
for geo in geos:
tweet_map.circle_marker(location=geo, radius=250)
tweet_map.create
答案 0 :(得分:0)
感谢#Python IRC频道的帮助:
for geo in geos:
#tweet_map.CircleMarker(location=geo, radius=250)
folium.CircleMarker(location=geo, radius=250).add_to(tweet_map)
tweet_map.save('map.html')