-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
35 lines (29 loc) · 1.04 KB
/
app.py
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
import streamlit as st
import pandas as pd
import plotly.express as px
import plot
# Predefined data sources
datasets = {
"National Health and Nutrition Examination Survey": {"file": "nhanes-2010.csv"},
"Framingham Heart Study": {"file": "fhs-2010.csv"},
}
# Streamlit selectbox inputs
dataset = st.selectbox("Dataset", datasets.keys())
measure = st.selectbox("Category", plot.measure_parameters.keys())
if(measure=="Biological Age" and dataset=="Framingham Heart Study"):
st.header("Framington Heart Study does not currently support Biological Age")
else:
# Load DataFrame
data_frame = pd.read_csv(datasets[dataset]["file"], index_col=0)
# Update figure based on chosen measure
survival_df = plot.build_plot(data_frame, plot.measure_parameters[measure])
# Create and display plot
fig = px.line(
survival_df,
x="Time (months)",
y="Survival",
color="Category",
hover_name="Survival",
range_y=[0, 1],
)
st.plotly_chart(fig, theme="streamlit", use_container_width=True)