-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 🎨 Update UI and Folium Map Refactored code for folium by adding custom icons and heatmap for visualizing allocation distribution. Also, replaced the dividers with inbuilt dividers of subheader and minor changes in displaying dataframe * 🧹 Remove cluttered code * 🎨 Added bubble chart within folium Replaced heatmap with circle mapper to display the proportion of the allocated students by using the size of the bubble
- Loading branch information
Showing
2 changed files
with
125 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
def pretty_dataframe(df): | ||
df = df.copy() | ||
df.columns = df.columns.str.replace("_", " ").str.title() | ||
|
||
return df | ||
|
||
def custom_map_zoom(lat, long): | ||
min_lat, max_lat = lat.min(), lat.max() | ||
min_long, max_long = long.min(), long.max() | ||
|
||
lat_diff = max_lat - min_lat | ||
long_diff = max_long - min_long | ||
|
||
# Base zoom levels for approximately 0.01 degree difference | ||
base_zoom_lat = 14 | ||
base_zoom_long = 14 | ||
|
||
# Adjust zoom level based on the span | ||
zoom_lat = base_zoom_lat - int((lat_diff // 0.05)) | ||
zoom_long = base_zoom_long - int((long_diff // 0.05)) | ||
|
||
# Return the smaller of the two zooms (more zoomed out) | ||
return min(zoom_lat, zoom_long) | ||
|
||
def custom_map_tooltip(row): | ||
tooltip = f""" | ||
<h6>{row['name'].title()}</h6> | ||
<strong>""" + ("📍 Center" if row['type'] == "Center" else "🏫 School") + f"""</strong><br/> | ||
<b>Latitude:</b> {row['lat']}<br/> | ||
<b>Longitude:</b> {row['long']}<br/> """ + ( | ||
f"""<b>Allocation:</b> {int(row['allocation'])}<br/>""" if row["allocation"] > 0 else "" | ||
) | ||
|
||
return tooltip |