Python Folium无法初始化地图位置类型错误

问题描述

我正在尝试使用folium进行数据可视化,但是我无法在创建地图时通过添加location参数来初始化地图位置。我的代码如下:

import folium
from folium.plugins import HeatMap

m = folium.Map(location=[54.251186,-4.463196])
HeatMap(heat_data,radius=9.5).add_to(m)
m

运行上面的代码时,出现以下错误

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-17-f3710e104270> in <module>
      8 
      9 #Heatmap
---> 10 m = folium.Map(location=[54.251186,-4.463196])
     11 HeatMap(heat_data,radius=9.5).add_to(m)
     12 m

~/opt/anaconda3/lib/python3.7/site-packages/folium/map.py in __init__(self,location,width,height,left,top,position,tiles,API_key,max_zoom,min_zoom,zoom_start,world_copy_jump,no_wrap,attr,min_lat,max_lat,min_lon,max_lon,max_bounds,detect_retina,crs,control_scale,prefer_canvas,no_touch,disable_3d,subdomains,png_enabled)
    167             self.zoom_start = min_zoom
    168         else:
--> 169             self.location = _validate_location(location)
    170             self.zoom_start = zoom_start
    171 

~/opt/anaconda3/lib/python3.7/site-packages/folium/utilities.py in _validate_location(location)
     28 def _validate_location(location):
     29     """Validates and formats location values before setting."""
---> 30     if _isnan(location):
     31         raise ValueError('Location values cannot contain NaNs,'
     32                          'got {!r}'.format(location))

~/opt/anaconda3/lib/python3.7/site-packages/folium/utilities.py in _isnan(values)
     70 def _isnan(values):
     71     """Check if there are NaNs values in the iterable."""
---> 72     return any(math.isnan(value) for value in _flatten(values))
     73 
     74 

TypeError: 'float' object cannot be interpreted as an integer

我试图在线搜索此问题,但是找不到任何答案。

感谢您的时间和精力!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)