Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import pandas as pd
|
2 |
import streamlit as st
|
3 |
import plotly.graph_objects as go
|
|
|
4 |
|
5 |
def create_sunburst_plot(df):
|
6 |
fig = go.Figure(go.Sunburst(
|
@@ -16,23 +17,30 @@ def create_sunburst_plot(df):
|
|
16 |
fig.update_layout(margin=dict(t=0, l=0, r=0, b=0))
|
17 |
return fig
|
18 |
|
19 |
-
# New data reflecting the CPT codes and expected costs
|
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': '
|
25 |
-
{'ids': '
|
26 |
-
{'ids': '
|
27 |
-
{'ids': '
|
28 |
]
|
29 |
|
30 |
df = pd.DataFrame(data)
|
31 |
|
32 |
-
#
|
33 |
-
def
|
34 |
-
|
|
|
|
|
35 |
|
36 |
-
|
|
|
37 |
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
|
|
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 |
+
# Function to update the data
|
33 |
+
def update_data(df):
|
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 |
+
plot_placeholder = st.empty()
|
40 |
|
41 |
+
# Loop to animate
|
42 |
+
for i in range(10): # Loop for 10 iterations
|
43 |
+
df = update_data(df)
|
44 |
+
fig = create_sunburst_plot(df)
|
45 |
+
plot_placeholder.plotly_chart(fig)
|
46 |
+
time.sleep(1) # Sleep for 1 second
|