Skip to content

Commit

Permalink
fix: change plotting with number-like feature name
Browse files Browse the repository at this point in the history
  • Loading branch information
RaczeQ committed Apr 27, 2023
1 parent 2283b18 commit 6b8037e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions srai/plotting/folium_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def plot_numeric_data(
folium.Map: Generated map.
"""
regions_gdf_copy = regions_gdf.copy()
regions_gdf_copy = regions_gdf_copy.merge(embedding_df, on=REGIONS_INDEX)
regions_gdf_copy = regions_gdf_copy.merge(embedding_df[[data_column]], on=REGIONS_INDEX)

if not isinstance(colormap, str):
colormap = _generate_linear_colormap(
Expand All @@ -112,9 +112,13 @@ def plot_numeric_data(
max_value=regions_gdf_copy[data_column].max(),
)

# Jinja2 rendering issue whne column is number-like. Workaround by using str column name.
# TypeError: '<' not supported between instances of 'float' and 'str'
regions_gdf_copy.rename(columns={data_column: "value"}, inplace=True)

return regions_gdf_copy.reset_index().explore(
column=data_column,
tooltip=[REGIONS_INDEX, data_column],
column="value",
tooltip=[REGIONS_INDEX, "value"],
tiles=tiles_style,
height=height,
width=width,
Expand Down

0 comments on commit 6b8037e

Please sign in to comment.