Spaces:
Sleeping
Sleeping
Update app.py
#1
by XPMaster - opened
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
|
| 3 |
st.set_page_config(layout="wide")
|
| 4 |
st.markdown("<h1 style='text-align: center;'>حسن xxx دحوم</h1>", unsafe_allow_html=True)
|
|
@@ -36,6 +37,24 @@ with button_col1:
|
|
| 36 |
else:
|
| 37 |
st.button(premiumlabel, disabled=True)
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
with button_col2:
|
| 40 |
if uploaded_file_claims_recoveries is not None:
|
| 41 |
st.button(incurredlabel)
|
|
@@ -49,3 +68,34 @@ with button_col3:
|
|
| 49 |
st.button(claimscount)
|
| 50 |
else:
|
| 51 |
st.button(claimscount, disabled=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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)
|
|
|
|
| 37 |
else:
|
| 38 |
st.button(premiumlabel, disabled=True)
|
| 39 |
|
| 40 |
+
def process_premiums_file(uploaded_file):
|
| 41 |
+
# Read the CSV file into a DataFrame
|
| 42 |
+
df = pd.read_csv(uploaded_file)
|
| 43 |
+
|
| 44 |
+
# Store the DataFrame in the session state
|
| 45 |
+
st.session_state['premiums_df'] = df
|
| 46 |
+
|
| 47 |
+
# Indicate that the CSV has been processed and we're ready to select columns
|
| 48 |
+
st.session_state['select_columns'] = True
|
| 49 |
+
|
| 50 |
+
# Button to select premiums, only enabled if a file has been uploaded
|
| 51 |
+
with button_col1:
|
| 52 |
+
if uploaded_file_premiums is not None:
|
| 53 |
+
if st.button(premiumlabel):
|
| 54 |
+
process_premiums_file(uploaded_file_premiums)
|
| 55 |
+
else:
|
| 56 |
+
st.button(premiumlabel, disabled=True)
|
| 57 |
+
|
| 58 |
with button_col2:
|
| 59 |
if uploaded_file_claims_recoveries is not None:
|
| 60 |
st.button(incurredlabel)
|
|
|
|
| 68 |
st.button(claimscount)
|
| 69 |
else:
|
| 70 |
st.button(claimscount, disabled=True)
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
# If the CSV has been processed, display the column selection UI
|
| 74 |
+
if st.session_state.get('select_columns', False):
|
| 75 |
+
st.write("Please choose the 'lob' column and the values to filter by:")
|
| 76 |
+
|
| 77 |
+
# Dropdown to select the 'lob' column
|
| 78 |
+
lob_column = st.selectbox('Choose the column for "lob":', st.session_state['premiums_df'].columns)
|
| 79 |
+
|
| 80 |
+
# Multiselect to choose values from the 'lob' column to filter the DataFrame
|
| 81 |
+
selected_lob_values = st.multiselect('Choose values from the "lob" column:',
|
| 82 |
+
st.session_state['premiums_df'][lob_column].unique())
|
| 83 |
+
|
| 84 |
+
# Filter the DataFrame based on selected 'lob' values
|
| 85 |
+
if selected_lob_values:
|
| 86 |
+
filtered_df = st.session_state['premiums_df'][st.session_state['premiums_df'][lob_column].isin(selected_lob_values)]
|
| 87 |
+
st.session_state['filtered_premiums_df'] = filtered_df
|
| 88 |
+
|
| 89 |
+
# Display other column selections after 'lob' has been selected and DataFrame has been filtered
|
| 90 |
+
st.write("Now, select the columns for other parameters:")
|
| 91 |
+
valuation_as_at = st.selectbox('Valuation As At:', filtered_df.columns)
|
| 92 |
+
quarter_bracket = st.selectbox('Quarter Bracket:', filtered_df.columns)
|
| 93 |
+
# Continue with other selections as required...
|
| 94 |
+
|
| 95 |
+
# Store the column selections in the session state
|
| 96 |
+
st.session_state['column_selections'] = {
|
| 97 |
+
'valuation_as_at': valuation_as_at,
|
| 98 |
+
'quarter_bracket': quarter_bracket,
|
| 99 |
+
# ... include other selections as well
|
| 100 |
+
}
|
| 101 |
+
|