import csv
import csv
import pandas as pd
import numpy as np
import streamlit as st
import base64
logo_path = r"C:\Users\PC\Desktop\FB_IMG_17285456011763622.jpg"
logo = Image.open(logo_path)
def convert_image_to_base64(image):
buffered = BytesIO()
image.save(buffered, format="PNG")
return base64.b64encode(buffered.getvalue()).decode()
logo_base64 = convert_image_to_base64(logo)
st.sidebar.markdown(
"""
<style>
.sidebar .sidebar-content {
.upload-button {
</style>
""",
unsafe_allow_html=True
)
st.sidebar.markdown(
f"""
<div style="width: 200px; height: 200px; border-radius: 150px; background-color: white; display: flex;
justify-content: center; align-items: center; margin: 0 auto;">
</div>
""",
unsafe_allow_html=True
df = None
try:
# Attempt to read the dataset
df = pd.read_csv(uploaded_file)
if df.empty:
else:
# Visualization section
st.session_state.visualize = True
years = [2020, 2021, 2022, 2023, 2024] # List of years to filter and plot
ax = axes[i]
ax.set_title(f'{year}', fontsize=14)
ax.set_xlabel('Month', fontsize=12)
if i == 0:
ax.set_xticks(range(1, 13))
ax.set_xticklabels([
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
])
plt.tight_layout()
plt.subplots_adjust(top=0.85)
st.pyplot(fig)
# Sidebar filters
# Filter by SEX
if sex_filter != "All":
df = df[df['SEX'] == sex_filter]
# Filter by AGE
if medical_aid_filter:
df = df[df['MEDICAL AID'].isin(medical_aid_filter)]
if not df.empty:
else:
except pd.errors.EmptyDataError:
except pd.errors.ParserError:
except Exception as e:
else: