Spaces:
Build error
Build error
Upload app.py
Browse files12345630 unmodified lines3738394041424344454647484950515253545556575859import streamlit as stimport pandas as pdimport altair as altst.set_page_config(page_title="IL Crop Rotation Explorer", layout="wide")30 unmodified linestitle='Crop Coverage Over Time (Filtered)')# ---- Heatmap: Crops by Land Use ----heatmap_data = filtered.groupby(['GenLU', 'crop_name']).size().reset_index(name='count')heatmap = alt.Chart(heatmap_data).mark_rect().encode(x=alt.X('GenLU:N', title='General Land Use', sort=genlu_options),y=alt.Y('crop_name:N', title='Dominant Crop', sort=crop_options),color=alt.Color('count:Q', scale=alt.Scale(scheme='greens'), title='Field Count'),tooltip=['GenLU', 'crop_name', 'count']).properties(width=800,height=500,title='Heatmap: Dominant Crops by General Land Use')# ---- Layout ----st.altair_chart(area_chart, use_container_width=True)st.altair_chart(heatmap, use_container_width=True)# ---- Discussion Section ----st.subheader("🧾 How to Use This Dashboard")123456730 unmodified lines383940414243444546474849505152535455565758596061626364656667686970import streamlit as stimport pandas as pdimport altair as altimport plotly.express as pxst.set_page_config(page_title="IL Crop Rotation Explorer", layout="wide")30 unmodified linestitle='Crop Coverage Over Time (Filtered)')# ---- Treemap: Crops by Land Use ----# Prepare the data (grouped field count)treemap_data = (filtered.groupby(['GenLU', 'crop_name']).size().reset_index(name='field_count'))# Drop rows with missing GenLU or crop_name just in casetreemap_data = treemap_data.dropna(subset=['GenLU', 'crop_name'])# Create treemaptreemap = px.treemap(treemap_data,path=['GenLU', 'crop_name'], # Hierarchyvalues='field_count',color='GenLU', # Optional coloringtitle='Treemap: Dominant Crops by Land Use Category')# Remove problematic 'customdata'treemap.data[0].customdata = None# ---- Layout ----st.altair_chart(area_chart, use_container_width=True)st.altair_chart(treemap, use_container_width=True)# ---- Discussion Section ----st.subheader("🧾 How to Use This Dashboard")
app.py+23-12