我不确定为什么输出只是HeatMapWithTime的空白区域,但是Heatmap运行正常。我使用http://nbviewer.jupyter.org/github/python-visualization/folium/blob/master/examples/HeatMapWithTime.ipynb作为参考点
df_cord2['weight'] = 1
cord_heat2 = df_cord2[['Lat','Long','weight']][0:100].values
date = df_cord2['date'][0:100]
print(date[:5]):
0 2018-11-17
1 2018-11-17
2 2018-11-17
3 2018-11-17
4 2018-11-17
Name: date, dtype: datetime64[ns]
print(cord_heat2[:5]):
[[ 34.1016 -118.3295 1. ]
[ 33.7115 -118.2879 1. ]
[ 34.0849 -118.3028 1. ]
[ 33.8637 -118.2905 1. ]
[ 34.0436 -118.2354 1. ]]
LA_coord = (34.0522,-118.243683)
m2= folium.Map(location=LA_coord,tiles= "Stamen Terrain",zoom_start=11)
hm = plugins.HeatMapWithTime(cord_heat2,index=date,auto_play=True)
hm.add_to(m2)
m2
我在这里想念什么?
编辑:几个小时后,终于找出问题所在。必须为cord_heat2创建一个列表类型
cord_heat2 =[cord_heat2.tolist()]