awacke1 commited on
Commit
3f2b322
·
1 Parent(s): 74c5c54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -10
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': '99213', 'labels': 'CPT 99213', 'parents': 'Hip Surgery', 'values': 300, 'text': 'Office Visit'},
25
- {'ids': '99214', 'labels': 'CPT 99214', 'parents': 'Hip Surgery', 'values': 400, 'text': 'Detailed Exam'},
26
- {'ids': '99284', 'labels': 'CPT 99284', 'parents': 'Knee Surgery', 'values': 250, 'text': 'Emergency Department Visit'},
27
- {'ids': '99285', 'labels': 'CPT 99285', 'parents': 'Knee Surgery', 'values': 450, 'text': 'Emergency Department Visit, High Complexity'},
28
  ]
29
 
30
  df = pd.DataFrame(data)
31
 
32
- # Filter DataFrame using a query parameter
33
- def filter_data(df, query):
34
- return df.query(query)
 
 
35
 
36
- filtered_df = filter_data(df, "parents == 'Root'")
 
37
 
38
- st.plotly_chart(create_sunburst_plot(filtered_df))
 
 
 
 
 
 
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