Sasidhar commited on
Commit
fbe48a0
·
1 Parent(s): 6d3f583

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -40
app.py CHANGED
@@ -78,6 +78,48 @@ def create_component_to_add_target_func(selected_files, dfs, i):
78
  # st.text(content)
79
  # st.write(f1(3))
80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
 
82
  def create_component_for_analysis_for_single_df(selected_files, dfs, i):
83
  st.subheader(selected_files[i])
@@ -86,46 +128,7 @@ def create_component_for_analysis_for_single_df(selected_files, dfs, i):
86
  filter_data = st.checkbox("Analyse on Filtered Data",key="filter_data_check"+str(i))
87
 
88
  if filter_data:
89
- action = "data_filter"
90
- col_to_filter = st.selectbox("Select the field to Filter on ", df.columns.values,
91
- key= action + "_col_filter_" + str(i))
92
- filter_operation = st.selectbox("Operation ",
93
- ['Greater Than', 'Equals', 'Less Than', "In", "In Between"],
94
- key=action + "_col_filter_op_" + str(i))
95
- selected_filter_vals = None
96
-
97
- if filter_operation:
98
- if filter_operation == 'In':
99
- selected_filter_vals = st.multiselect("Select Values to Filter on ", df[col_to_filter].unique(),
100
- key=action + "_col_filter_val_" + str(i))
101
- if selected_filter_vals:
102
- filtered_df = df[df[col_to_filter].isin(selected_filter_vals)]
103
- elif filter_operation == 'Equals':
104
- selected_filter_vals = st.text_input("Enter a numeric value",
105
- key=action + "_col_filter_val_" + str(i))
106
- if selected_filter_vals:
107
- filtered_df = df[df[col_to_filter] == selected_filter_vals]
108
- elif filter_operation == 'Greater Than':
109
- selected_filter_vals = st.text_input("Enter a numeric value",
110
- key=action + "_col_filter_val_" + str(i))
111
- if selected_filter_vals:
112
- filtered_df = df[df[col_to_filter] > selected_filter_vals]
113
- elif filter_operation == 'Less Than':
114
- selected_filter_vals = st.text_input("Enter a numeric value",
115
- key=action + "_col_filter_val_" + str(i))
116
- if selected_filter_vals:
117
- filtered_df = df[df[col_to_filter] < selected_filter_vals]
118
- elif filter_operation == 'In Between':
119
- selected_filter_vals = st.select_slider("Select range",
120
- (df[col_to_filter].min(), df[col_to_filter].max()),
121
- key=action + "_col_filter_val_" + str(i))
122
- if selected_filter_vals:
123
- filtered_df = df[df[col_to_filter] < selected_filter_vals]
124
-
125
- if selected_filter_vals:
126
- set_filtered_data_session_object(filtered_df,selected_files[i])
127
- # st.write(df.shape)
128
- # st.write( st.session_state['filtered_data'][selected_files[i]].shape)
129
 
130
  analysis_actions = st.multiselect("What analysis do you wish to do?",
131
  ['Summary of Data', 'Sample Data','Get Profile' ,'Univariate Analysis',
 
78
  # st.text(content)
79
  # st.write(f1(3))
80
 
81
+ def set_filtered_data(df,i):
82
+ action = "data_filter"
83
+ col_to_filter = st.selectbox("Select the field to Filter on ", df.columns.values,
84
+ key= action + "_col_filter_" + str(i))
85
+ filter_operation = st.selectbox("Operation ",
86
+ ['Greater Than', 'Equals', 'Less Than', "In", "In Between"],
87
+ key=action + "_col_filter_op_" + str(i))
88
+ selected_filter_vals = None
89
+
90
+ if filter_operation:
91
+ if filter_operation == 'In':
92
+ selected_filter_vals = st.multiselect("Select Values to Filter on ", df[col_to_filter].unique(),
93
+ key=action + "_col_filter_val_" + str(i))
94
+ if selected_filter_vals:
95
+ filtered_df = df[df[col_to_filter].isin(selected_filter_vals)]
96
+ elif filter_operation == 'Equals':
97
+ selected_filter_vals = st.text_input("Enter a numeric value",
98
+ key=action + "_col_filter_val_" + str(i))
99
+ if selected_filter_vals:
100
+ filtered_df = df[df[col_to_filter] == selected_filter_vals]
101
+ elif filter_operation == 'Greater Than':
102
+ selected_filter_vals = st.text_input("Enter a numeric value",
103
+ key=action + "_col_filter_val_" + str(i))
104
+ if selected_filter_vals:
105
+ filtered_df = df[df[col_to_filter] > selected_filter_vals]
106
+ elif filter_operation == 'Less Than':
107
+ selected_filter_vals = st.text_input("Enter a numeric value",
108
+ key=action + "_col_filter_val_" + str(i))
109
+ if selected_filter_vals:
110
+ filtered_df = df[df[col_to_filter] < selected_filter_vals]
111
+ elif filter_operation == 'In Between':
112
+ selected_filter_vals = st.select_slider("Select range",
113
+ (df[col_to_filter].min(), df[col_to_filter].max()),
114
+ key=action + "_col_filter_val_" + str(i))
115
+ if selected_filter_vals:
116
+ filtered_df = df[df[col_to_filter] < selected_filter_vals]
117
+
118
+ if selected_filter_vals:
119
+ set_filtered_data_session_object(filtered_df,selected_files[i])
120
+ # st.write(df.shape)
121
+ # st.write( st.session_state['filtered_data'][selected_files[i]].shape)
122
+
123
 
124
  def create_component_for_analysis_for_single_df(selected_files, dfs, i):
125
  st.subheader(selected_files[i])
 
128
  filter_data = st.checkbox("Analyse on Filtered Data",key="filter_data_check"+str(i))
129
 
130
  if filter_data:
131
+ set_filtered_data()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
 
133
  analysis_actions = st.multiselect("What analysis do you wish to do?",
134
  ['Summary of Data', 'Sample Data','Get Profile' ,'Univariate Analysis',