문제 설명
Geodataframe.explore() 오류: init() 누락된 1개의 필수 위치 인수: '위치' (Geodataframe.explore() error: init() missing 1 required positional argument: 'location')
Colab에서 Geopandas와 그 explore() 메서드를 사용하여 대화형 지도를 구성하려고 합니다.
하지만 다음을 작성할 때:
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])
하지만 오류는 여전히 남아 있습니다.
스페인의 주별 실업률을 보여주는 지도를 만들고 있습니다. 지리 데이터는 다음 소스에서 다운로드할 수 있습니다.
http://centrodedescargas.cnig.es/CentroDescargas/buscar.do?filtro.codFamilia=LILIM&filtro.codCA=11#
참조 솔루션
방법 1:
The first positional argument to geopandas.GeoDataFrame.explore
is column
:
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.
If you're plotting a dataframe with more than one column, be sure to provide the name of the column you would like to explore, as in:
my_geodataframe.explore('Tasa_Paro')
방법 2:
The code above is correct. The issue is that you are using the old, unsupported version of folium. GeoPandas explore
has been designed to work with folium 0.12 and newer, you need to update.
(by AlejandroDGR、Michael Delgado、martinfleis)