Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,19 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
st.set_page_config(layout="wide")
|
| 5 |
st.markdown("<h1 style='text-align: center;'>حسن xxx دحوم</h1>", unsafe_allow_html=True)
|
|
@@ -66,13 +80,18 @@ with button_col3:
|
|
| 66 |
st.button(claimscount, disabled=True)
|
| 67 |
|
| 68 |
|
|
|
|
|
|
|
|
|
|
| 69 |
# If the CSV has been processed, display the column selection UI
|
| 70 |
if st.session_state.get('select_columns', False):
|
| 71 |
st.write("Please choose the 'lob' column and the values to filter by:")
|
| 72 |
|
| 73 |
-
# Determine columns with only string values
|
| 74 |
-
string_columns = [
|
| 75 |
-
|
|
|
|
|
|
|
| 76 |
|
| 77 |
# Create two columns: one for the 'lob' column dropdown, one for the checkboxes
|
| 78 |
col1, col2 = st.columns(2)
|
|
@@ -80,7 +99,6 @@ if st.session_state.get('select_columns', False):
|
|
| 80 |
# Dropdown to select the 'lob' column, filtered to only string columns
|
| 81 |
with col1:
|
| 82 |
lob_column = st.selectbox('Choose the column for "lob":', string_columns, key='lob_column')
|
| 83 |
-
|
| 84 |
# Initialize an empty list to hold the selected values
|
| 85 |
selected_lob_values = []
|
| 86 |
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
+
import re
|
| 4 |
+
|
| 5 |
+
# Helper function to check if a string has more than 50% numeric characters
|
| 6 |
+
def is_mostly_numeric(s):
|
| 7 |
+
if isinstance(s, str):
|
| 8 |
+
# Remove any whitespace and punctuation that should not count towards the numeric content
|
| 9 |
+
s = re.sub(r'[^\w\s]', '', s)
|
| 10 |
+
# Calculate the number of numeric characters
|
| 11 |
+
num_numeric = sum(c.isdigit() for c in s)
|
| 12 |
+
# Calculate the percentage of numeric characters
|
| 13 |
+
percent_numeric = num_numeric / len(s) if s else 0
|
| 14 |
+
return percent_numeric > 0.5
|
| 15 |
+
return False
|
| 16 |
+
|
| 17 |
|
| 18 |
st.set_page_config(layout="wide")
|
| 19 |
st.markdown("<h1 style='text-align: center;'>حسن xxx دحوم</h1>", unsafe_allow_html=True)
|
|
|
|
| 80 |
st.button(claimscount, disabled=True)
|
| 81 |
|
| 82 |
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
|
| 86 |
# If the CSV has been processed, display the column selection UI
|
| 87 |
if st.session_state.get('select_columns', False):
|
| 88 |
st.write("Please choose the 'lob' column and the values to filter by:")
|
| 89 |
|
| 90 |
+
# Determine columns with only string values and where no value is mostly numeric
|
| 91 |
+
string_columns = [
|
| 92 |
+
col for col in st.session_state['premiums_df'].columns
|
| 93 |
+
if st.session_state['premiums_df'][col].dropna().apply(lambda x: isinstance(x, str) and not is_mostly_numeric(x)).all()
|
| 94 |
+
]
|
| 95 |
|
| 96 |
# Create two columns: one for the 'lob' column dropdown, one for the checkboxes
|
| 97 |
col1, col2 = st.columns(2)
|
|
|
|
| 99 |
# Dropdown to select the 'lob' column, filtered to only string columns
|
| 100 |
with col1:
|
| 101 |
lob_column = st.selectbox('Choose the column for "lob":', string_columns, key='lob_column')
|
|
|
|
| 102 |
# Initialize an empty list to hold the selected values
|
| 103 |
selected_lob_values = []
|
| 104 |
|