Skip to content

Commit f05f3ce

Browse files
evwhizConengmo
authored andcommitted
Choropleth: add message when key_on not found in data (#1144)
Raise a value error when the `key_on` parameter was not found in the geojson data in Choropleth.
1 parent 3b8f6e5 commit f05f3ce

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

folium/features.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,8 @@ def get_by_key(obj, key):
11091109

11101110
def color_scale_fun(x):
11111111
key_of_x = get_by_key(x, key_on)
1112+
if not key_of_x:
1113+
raise ValueError("key_on `{!r}` not found in GeoJSON.".format(key_on))
11121114

11131115
if key_of_x not in color_data.keys():
11141116
return nan_fill_color, nan_fill_opacity

0 commit comments

Comments
 (0)