import streamlit as st import pandas as pd # Load the cleaned data df = pd.read_csv('cleaned_farmer_data.csv') # Set the page configuration for better layout and dark theme st.set_page_config( page_title="Agroforestry Program Dashboard", page_icon="🌱", layout="wide", ) # Custom CSS for dark theme and background color adjustments st.markdown(""" """, unsafe_allow_html=True) # Title and header for the dashboard st.markdown('
Real-Time Insights for Farmers
', unsafe_allow_html=True) # Sidebar for navigation with a cleaner layout st.sidebar.header("Dashboard Navigation") section = st.sidebar.radio( "Select a Section:", ['Overview', 'Data Quality Issues', 'Plantation Progress', 'Location Insights'] ) # Overview Section if section == 'Overview': st.subheader("📊 Overall Statistics") # Display key metrics in a clean, organized way total_area = df['total_land_area_acre'].sum() # Corrected column name total_plantation_area = df['area_f4f_acre'].sum() # Assuming 'area_f4f_acre' represents plantation area # Calculate the number of rows with missing or erroneous data missing_data_count = df.isnull().sum().sum() # Total missing values in the dataset st.markdown(f"""

Total Area (Acres)

{total_area}

Total Plantation Area (Acres)

{total_plantation_area}

Missing Data Entries

{missing_data_count}

""", unsafe_allow_html=True) # Data Quality Issues Section elif section == 'Data Quality Issues': st.subheader("⚠️ Data Quality Issues") # Check for missing or erroneous data missing_data = df[df.isnull().any(axis=1)] # Rows with missing values # Search functionality to filter results by farmer name search_term = st.text_input("🔍 Search by Farmer Name", "").strip().lower() if search_term: missing_data = missing_data[missing_data['farmer_name'].str.lower().str.contains(search_term)] if not missing_data.empty: st.write(f"**Displaying {len(missing_data)} records with data quality issues:**") st.dataframe(missing_data) else: st.write("🎉 No data quality issues found!") # Plantation Progress Section elif section == 'Plantation Progress': st.subheader("🌿 Plantation Progress") # Check if plantation area percentage data exists if 'area_f4f_acre' in df.columns and 'total_land_area_acre' in df.columns: df['plantation_area_percentage'] = (df['area_f4f_acre'] / df['total_land_area_acre']) * 100 st.bar_chart(df['plantation_area_percentage']) else: st.warning("⚠️ No plantation progress data available!") # Location Insights Section elif section == 'Location Insights': st.subheader("📍 Plantation Area by Location") # Display the plantation area by district or location if 'District' in df.columns and 'area_f4f_acre' in df.columns: location_distribution = df.groupby('District')['area_f4f_acre'].sum().reset_index() st.bar_chart(location_distribution.set_index('District')['area_f4f_acre']) else: st.warning("⚠️ Location or plantation area data is missing!") # Footer with contact info st.markdown(""" --- **Developed by:** [Anupam Joshi](+918847374914) **📧 Contact:** stylehope44@gmail.com """)