Sander Su commited on
Commit
fa2ea7a
·
1 Parent(s): 76778c8
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+
4
+ # Load the data
5
+ @st.cache
6
+ def load_data():
7
+ data_url = 'https://phewascatalog.org/files/Phecode_map_v1_2_icd10cm_beta.csv'
8
+ data = pd.read_csv(data_url, encoding='ISO-8859-1')
9
+ return data
10
+
11
+ data = load_data()
12
+
13
+ # Search functionality
14
+ def search_data(data, query, columns):
15
+ return data[data[columns].apply(lambda x: query.lower() in str(x).lower(), axis=1)]
16
+
17
+ # Get the search query and the selected columns from the user
18
+ search_query = st.text_input("Search query", "")
19
+ search_columns = st.multiselect("Search in columns", data.columns.tolist(), default=data.columns.tolist())
20
+
21
+ # Filter the data
22
+ filtered_data = search_data(data, search_query, search_columns)
23
+
24
+ # Pagination
25
+ page_size = 25
26
+ page_number = st.number_input(label="Page Number", min_value=1, max_value=len(filtered_data)//page_size, step=1)
27
+
28
+ # Display the data
29
+ st.write(filtered_data.iloc[page_size*(page_number-1):page_size*page_number])