python - Geodataframe.explore()错误: __init__() missing 1 required positional argument: 'location'

标签 python dictionary geopandas

我正在尝试使用 Geopandas 及其在 Colab 中的 explore() 方法绘制交互式 map 。

但是,当我写时:

my_geodataframe.explore()

出现以下错误:

TypeError                                 Traceback (most recent call last)
<ipython-input-11-e71fb33b059f> in <module>()
----> 1 mapa_interactivo = mapa1.explore()

1 frames
/usr/local/lib/python3.7/dist-packages/geopandas/explore.py in _explore(df, column, cmap, color, m, tiles, attr, tooltip, popup, highlight, categorical, legend, scheme, k, vmin, vmax, width, height, categories, classification_kwds, control_scale, marker_type, marker_kwds, style_kwds, highlight_kwds, missing_kwds, tooltip_kwds, popup_kwds, legend_kwds, **kwargs)
    511             marker_kwds["radius"] = marker_kwds.get("radius", 2)
    512             marker_kwds["fill"] = marker_kwds.get("fill", True)
--> 513             marker = folium.CircleMarker(**marker_kwds)
    514         else:
    515             raise ValueError(

TypeError: __init__() missing 1 required positional argument: 'location'

我明确写下了位置:

my_geodataframe.explore(location=[40.463667, -3.74922])

但错误仍然存​​在。

我正在创建显示西类牙每个省的失业率的 map 。地理数据可以从以下来源下载:

http://centrodedescargas.cnig.es/CentroDescargas/buscar.do?filtro.codFamilia=LILIM&filtro.codCA=11#

各省的失业率数据可以从这个下载:

https://www.ine.es/jaxiT3/Datos.htm?t=3996

将信息合并到一个独特的地理数据框中后,我得到如下结果:

<表类=“s-表”> <标题> 省 Codigo Tasa_Paro 几何 <正文> 瓦伦西亚/瓦伦​​西亚 46 14.75 多重多边形 (((-1.20715 40.00183, -1.21662 40... 托莱多 45 16.77 多边形((-5.40611 39.87773,-5.40618 39.87884... 特鲁埃尔 44 10.60 多边形 ((0.14136 40.71821, 0.12382 40.72081, ... 塔拉戈纳 43 15.51 多重多边形 (((0.70759 40.63522, 0.70732 40.6... 索里亚 42 9.73 多边形((-1.99369 41.57709,-1.99311 41.57646...

我已经能够毫无问题地绘制静态分区统计图:

Unemployment rate per province. Spain. 2021T1

您可以在以下链接中找到我用来绘制它的代码:

https://github.com/AlejandroDGR/Proyecto_Difusion_Universitarios_INE/blob/master/Casos_de_uso_Python/C%C3%B3mo%20dibujar%20mapas%20est%C3%A1ticos%20en%20Python.ipynb

如上所述,问题是在尝试绘制交互式 map 时出现的。

有什么建议吗?

最佳答案

geopandas.GeoDataFrame.explore 的第一个位置参数是:

column: str, np.array, pd.Series (default None)
The name of the dataframe column, numpy.array, or pandas.Series to be plotted. If numpy.array or pandas.Series are used then it must have same length as dataframe.

如果您要绘制包含多个列的数据框,请务必提供您想要探索的列的名称,如下所示:

my_geodataframe.explore('Tasa_Paro')

关于python - Geodataframe.explore()错误: __init__() missing 1 required positional argument: 'location' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71239094/

相关文章:

python - ValueError : Input shapes do not overlap raster. Geopandas/Rasterio,屏蔽时可能出现 CRS 错误

python - 查找组的最大值返回整行 Pandas

python - 解析 imaplib 返回的 Message-ID header

python - Numpy 在另一个数组中查找元素索引

c# - 从 C# 中的字典匹配正则表达式

python - 从两个列表构建字典

c# 保存要查找的值列表的最佳类

python - 为什么 lambda 函数执行时间在作为可调用函数传递时与作为字符串语句传递给 timeit.repeat() 时不同?

python - Geopandas 连接形状文件的着色

python - 两点层之间的距离矩阵