Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,47 +1,17 @@
|
|
1 |
import pandas as pd
|
|
|
2 |
import streamlit as st
|
3 |
-
import plotly.graph_objects as go
|
4 |
-
import time
|
5 |
-
|
6 |
-
def create_sunburst_plot(df):
|
7 |
-
fig = go.Figure(go.Sunburst(
|
8 |
-
labels=df['labels'],
|
9 |
-
parents=df['parents'],
|
10 |
-
values=df['values'],
|
11 |
-
ids=df['ids'],
|
12 |
-
text=df['text'],
|
13 |
-
hoverinfo="label+value",
|
14 |
-
branchvalues="total",
|
15 |
-
))
|
16 |
-
|
17 |
-
fig.update_layout(margin=dict(t=0, l=0, r=0, b=0))
|
18 |
-
return fig
|
19 |
-
|
20 |
-
data = [
|
21 |
-
{'ids': 'Root', 'labels': 'Root', 'parents': '', 'values': None, 'text': 'Root'},
|
22 |
-
{'ids': 'Hip Surgery', 'labels': 'Hip Surgery', 'parents': 'Root', 'values': 30, 'text': 'Hip Surgery'},
|
23 |
-
{'ids': 'Knee Surgery', 'labels': 'Knee Surgery', 'parents': 'Root', 'values': 40, 'text': 'Knee Surgery'},
|
24 |
-
{'ids': 'CPT1', 'labels': 'CPT1', 'parents': 'Hip Surgery', 'values': 20, 'text': 'CPT1'},
|
25 |
-
{'ids': 'CPT2', 'labels': 'CPT2', 'parents': 'Hip Surgery', 'values': 10, 'text': 'CPT2'},
|
26 |
-
{'ids': 'CPT3', 'labels': 'CPT3', 'parents': 'Knee Surgery', 'values': 25, 'text': 'CPT3'},
|
27 |
-
{'ids': 'CPT4', 'labels': 'CPT4', 'parents': 'Knee Surgery', 'values': 15, 'text': 'CPT4'},
|
28 |
-
]
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
df = pd.DataFrame(data)
|
31 |
|
32 |
-
#
|
33 |
-
|
34 |
-
# Here you can add your logic to vary the cost data
|
35 |
-
df['values'] = df['values'] + 5
|
36 |
-
return df
|
37 |
-
|
38 |
-
# Create a placeholder for the plot
|
39 |
-
# animate the chart by incrementing the cost values and updating the chart every second. You can adjust the update_data function to customize the variations in the data.
|
40 |
|
41 |
-
#
|
42 |
-
|
43 |
-
df = update_data(df)
|
44 |
-
fig = create_sunburst_plot(df)
|
45 |
-
#st.plot(create_sunburst_plot(df))
|
46 |
-
st.plotly_chart(create_sunburst_plot(df))
|
47 |
-
time.sleep(5) # Sleep for 5 seconds
|
|
|
1 |
import pandas as pd
|
2 |
+
import plotly.express as px
|
3 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
+
# Create a DataFrame with CPT codes, procedures, and expected costs
|
6 |
+
data = {
|
7 |
+
'CPT Code': ['99201', '99232', '99233', '99234', '99235'],
|
8 |
+
'Procedure': ['Office/Outpatient Visit', 'Inpatient Consultation', 'Initial Hospital Care', 'Subsequent Hospital Care', 'Critical Care Services'],
|
9 |
+
'Expected Cost': [100, 200, 150, 250, 300]
|
10 |
+
}
|
11 |
df = pd.DataFrame(data)
|
12 |
|
13 |
+
# Create a histogram with Plotly Express
|
14 |
+
fig = px.histogram(df, x='Procedure', y='Expected Cost')
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
+
# Display the histogram in Streamlit
|
17 |
+
st.plotly_chart(fig)
|
|
|
|
|
|
|
|
|
|