Spaces:
Build error
Build error
Create app.py
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657import streamlit as stimport pandas as pdimport matplotlib.pyplot as pltimport plotly.express as px
# Title and Descriptionst.title('Patient Data Dashboard')st.write("""This dashboard provides an overview of patient health metrics for better monitoring and decision-making.""")
# Load Patient Data (Example DataFrame)df = pd.read_csv('patient_data.csv')
# Sidebar for Patient Selectionst.sidebar.header('Select Patient')patient_id = st.sidebar.selectbox('Patient ID', df['patient_id'].unique())
# Filter Data for Selected Patientpatient_data = df[df['patient_id'] == patient_id]
# Display Patient Profilest.header('Patient Profile')st.write(f"Name: {patient_data['name'].values[0]}")st.write(f"Age: {patient_data['age'].values[0]}")st.write(f"Gender: {patient_data['gender'].values[0]}")st.write(f"Medical History: {patient_data['medical_history'].values[0]}")
# Visualize Vital Signsst.header('Vital Signs Over Time')fig, ax = plt.subplots()ax.plot(patient_data['date'], patient_data['heart_rate'], label='Heart Rate')ax.plot(patient_data['date'], patient_data['blood_pressure'], label='Blood Pressure')ax.set_xlabel('Date')ax.set_ylabel('Value')ax.legend()st.pyplot(fig)
# Interactive Plotly Chartst.header('Blood Glucose Levels')fig = px.line(patient_data, x='date', y='blood_glucose', title='Blood Glucose Over Time')st.plotly_chart(fig)
# Alerts and Notificationsst.header('Alerts')if patient_data['heart_rate'].values[-1] > 100: st.error('High heart rate detected!')if patient_data['blood_pressure'].values[-1] > 140: st.error('High blood pressure detected!')
# Download Button for Patient Datast.download_button( label="Download Patient Data as CSV", data=patient_data.to_csv().encode('utf-8'), file_name=f'patient_{patient_id}_data.csv', mime='text/csv',)app.pyAdded+57