AMKhakbaz commited on
Commit
089632b
·
verified ·
1 Parent(s): c656414

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -2
app.py CHANGED
@@ -486,6 +486,11 @@ def all_tabulation(df, main_dict, follow_dict):
486
  st.subheader(j)
487
  st.dataframe(join_dataframes(name_list, dataframe_list))
488
 
 
 
 
 
 
489
 
490
  empty_col1, main_col, empty_col2 = st.columns([1.6, 2.8, 1.6])
491
 
@@ -512,7 +517,7 @@ if uploaded_file:
512
  st.subheader("Displaying the first few rows of the DataFrame")
513
  st.dataframe(df.head())
514
 
515
- main_option = st.selectbox("Please select an option:", ["Tabulation", "Funnel", "Hypothesis test", "Machine Learning", "Coding"])
516
 
517
  if main_option == "Tabulation":
518
  st.header("Tabulation Analysis")
@@ -692,7 +697,7 @@ if uploaded_file:
692
  else:
693
  st.info("This section of the program is under development.")
694
 
695
- elif main_option == "Funnel":
696
  st.header("Funnel")
697
 
698
  cols = edit_strings(df.columns)
@@ -776,6 +781,38 @@ if uploaded_file:
776
 
777
  st.plotly_chart(fig)
778
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
779
 
780
  elif main_option == "Hypothesis test":
781
  st.header("Hypothesis Testing")
 
486
  st.subheader(j)
487
  st.dataframe(join_dataframes(name_list, dataframe_list))
488
 
489
+ def process_dataframe(df):
490
+ df = df.fillna(0)
491
+ for col in df.columns:
492
+ df[col] = pd.Categorical(df[col])
493
+ return df
494
 
495
  empty_col1, main_col, empty_col2 = st.columns([1.6, 2.8, 1.6])
496
 
 
517
  st.subheader("Displaying the first few rows of the DataFrame")
518
  st.dataframe(df.head())
519
 
520
+ main_option = st.selectbox("Please select an option:", ["Tabulation", "Funnel Analysis", "Segmentation Analysis", "Hypothesis test", "Machine Learning", "Coding"])
521
 
522
  if main_option == "Tabulation":
523
  st.header("Tabulation Analysis")
 
697
  else:
698
  st.info("This section of the program is under development.")
699
 
700
+ elif main_option == "Funnel Analysis":
701
  st.header("Funnel")
702
 
703
  cols = edit_strings(df.columns)
 
781
 
782
  st.plotly_chart(fig)
783
 
784
+ elif main_option == "Segmentation Analysis":
785
+ st.header("Segmentation Analysis")
786
+
787
+ cols = edit_strings(df.columns)
788
+ cols = sorted(list(set(cols)))
789
+
790
+ st.sidebar.header("Selection of questions")
791
+ single_list = st.sidebar.multiselect(
792
+ 'Single answer questions',
793
+ cols,
794
+ default=[]
795
+ )
796
+
797
+ multi_list = st.sidebar.multiselect(
798
+ 'Multi answer questions',
799
+ cols,
800
+ default=[]
801
+ )
802
+
803
+ score_list = st.sidebar.multiselect(
804
+ 'Score answer questions',
805
+ cols,
806
+ default=[]
807
+ )
808
+
809
+ matching_cols1 = []
810
+ for i in multi_list:
811
+ matching_cols1 += [col for col in df.columns if is_matching_pattern(col, var1)]
812
+
813
+ df_clean = process_dataframe(df[single_list + matching_cols1])
814
+ st.dataframe(df_clean)
815
+
816
 
817
  elif main_option == "Hypothesis test":
818
  st.header("Hypothesis Testing")