Spaces:
Build error
Build error
File size: 5,067 Bytes
94ac24a b30530a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
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("""
<style>
body {
background-color: #121212; /* Dark background color */
color: white; /* Text color set to white */
}
.sidebar .sidebar-content {
background-color: #1e1e1e; /* Dark sidebar background */
color: white; /* Sidebar text color */
}
.stButton>button {
background-color: #4CAF50; /* Green button color */
color: white; /* Button text color */
}
.title {
text-align: center;
font-size: 40px;
color: #4CAF50;
}
.stMarkdown {
background-color: #1e1e1e; /* Dark background for markdown blocks */
}
.stTable {
background-color: #1e1e1e; /* Dark background for table blocks */
}
.stDataFrame {
background-color: #1e1e1e; /* Dark background for dataframe */
}
</style>
""", unsafe_allow_html=True)
# Title and header for the dashboard
st.markdown('<div class="title">Real-Time Insights for Farmers</div>', 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"""
<div style="display: flex; justify-content: space-around; margin-top: 20px;">
<div style="padding: 10px; background-color: #333333; border-radius: 8px; width: 30%; text-align: center;">
<h3>Total Area (Acres)</h3>
<p style="font-size: 30px; color: #4CAF50;">{total_area}</p>
</div>
<div style="padding: 10px; background-color: #333333; border-radius: 8px; width: 30%; text-align: center;">
<h3>Total Plantation Area (Acres)</h3>
<p style="font-size: 30px; color: #4CAF50;">{total_plantation_area}</p>
</div>
<div style="padding: 10px; background-color: #333333; border-radius: 8px; width: 30%; text-align: center;">
<h3>Missing Data Entries</h3>
<p style="font-size: 30px; color: #f44336;">{missing_data_count}</p>
</div>
</div>
""", 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:** [Satyam Kumar](https://github.com/Satyam0775)
**π§ Contact:** Satyamrishav0013@gmail.com
""") |