Update pages/chapter_index.py
Browse files- pages/chapter_index.py +23 -2
pages/chapter_index.py
CHANGED
@@ -1,14 +1,35 @@
|
|
1 |
import streamlit as st
|
2 |
-
import pandas as pd
|
|
|
3 |
|
4 |
#st.title("📘SBS mapper")
|
5 |
#st.write("Map internal descriptions to SBS codes in the below chapters* (work in progress)")
|
6 |
#st.image("images/SBS_Chapter_Index.png", use_container_width=True)
|
7 |
-
st.
|
8 |
df_chapters = pd.read_csv("SBS_V2_Chapter_Index.csv")
|
9 |
df_chapters.iloc[25] = {"Chapter": "ALL", "Chapter title": "ALL TOPICS (will take more time)", "Blocks": "Total", "No. Codes": 10081}
|
10 |
st.dataframe(df_chapters, hide_index=True)
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
st.subheader("* Demo currently limited to Chapter 20: Imaging services")
|
13 |
|
14 |
#'Procedures on nervous system'
|
|
|
1 |
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
#import numpy as np
|
4 |
|
5 |
#st.title("📘SBS mapper")
|
6 |
#st.write("Map internal descriptions to SBS codes in the below chapters* (work in progress)")
|
7 |
#st.image("images/SBS_Chapter_Index.png", use_container_width=True)
|
8 |
+
st.header("Select specific topic for quicker results")
|
9 |
df_chapters = pd.read_csv("SBS_V2_Chapter_Index.csv")
|
10 |
df_chapters.iloc[25] = {"Chapter": "ALL", "Chapter title": "ALL TOPICS (will take more time)", "Blocks": "Total", "No. Codes": 10081}
|
11 |
st.dataframe(df_chapters, hide_index=True)
|
12 |
|
13 |
+
def dataframe_with_selections(df: pd.DataFrame, init_value: bool = False) -> pd.DataFrame:
|
14 |
+
df_with_selections = df.copy()
|
15 |
+
df_with_selections.insert(0, "Select", init_value)
|
16 |
+
|
17 |
+
# Get dataframe row-selections from user with st.data_editor
|
18 |
+
edited_df = st.data_editor(
|
19 |
+
df_with_selections,
|
20 |
+
hide_index=True,
|
21 |
+
column_config={"Select": st.column_config.CheckboxColumn(required=True)},
|
22 |
+
disabled=df.columns,
|
23 |
+
)
|
24 |
+
|
25 |
+
# Filter the dataframe using the temporary column, then drop the column
|
26 |
+
selected_rows = edited_df[edited_df.Select]
|
27 |
+
return selected_rows.drop('Select', axis=1)
|
28 |
+
|
29 |
+
selection = dataframe_with_selections(df)
|
30 |
+
st.write("Your selection:")
|
31 |
+
st.write(selection)
|
32 |
+
|
33 |
st.subheader("* Demo currently limited to Chapter 20: Imaging services")
|
34 |
|
35 |
#'Procedures on nervous system'
|