1

I'm working on producing a series of maps for an animated presentation using Folium and my code (when plotting over 100 circles) always ends in a blank map. If I decrease the number of circles to 100 or below, it works perfectly. Is this a folium limitation or something I can change on my local machine with Java or Browser settings? I'm using python in jupyter notebook in chrome on Ubuntu. merged_hourly is a pandas df with nyc foottraffic data for specific stations, lat, long, etc.

Exported Dataframe is located here as a spreadsheet: https://docs.google.com/spreadsheets/d/1XroOBPUWOqZsy-l1dwcR1iuOIn9ln69ylO16_Sqa9yc/edit?usp=sharing

# iterates columns in df
for myint in range(0,241):
    # iterates rows in df. should go to ~289, but will make a blank map
    for i in range(0,101):
        # sets some variables from the df
        R=merged_hourly[str(myint/10)][i]*.15
        lat=merged_hourly['Station_Latitude'][i]
        long=merged_hourly['Station_Longitude'][i]
        stname=merged_hourly['Station_Name'][i]
        # plots the CircleMarker
        folium.CircleMarker([lat, long], radius=R, popup=stname, color='#3186cc', 
                            fill_color='#3186cc',fill=True,
                            fill_opacity= .7).add_to(map_final)
    # saves a map with all the circle markers in a row
    map_final.save("FilePath/"+str(myint)+'.html')
    map_final=5
    map_final=folium.Map(location=[40.775036, -73.912034], zoom_start=11.25)
4

1 回答 1

4

OP 的数据集在 Station_Name 列/系列中包含一个带有撇号/单引号的行,该行没有导致错误,但也没有渲染地图。

filter = merged_hourly['Station_Name'].str.contains("'")
print(merged_hourly.loc[filter,'Station_Name'])

101    E 143/ST MARY'S
Name: Station_Name, dtype: object

解决方案是替换撇号,'以便地图渲染和 Station_Name 正确显示在弹出窗口中

merged_hourly['Station_Name'] = merged_hourly['Station_Name']
                                              .str.replace("'", "'")
于 2017-09-24T02:46:46.153 回答