AMKhakbaz commited on
Commit
3960861
·
verified ·
1 Parent(s): 1ff1c62

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +157 -157
app.py CHANGED
@@ -517,182 +517,182 @@ if uploaded_file:
517
  if main_option == "Tabulation":
518
  st.header("Tabulation Analysis")
519
 
520
- tabulation_option = st.selectbox("Please select the type of analysis:", ["Univariate", "Multivariate", "All"])
521
-
522
- if tabulation_option == "All":
523
-
524
- cols = edit_strings(df.columns)
525
- cols = sorted(list(set(cols)))
526
-
527
- st.sidebar.header("Settings")
528
-
529
- main_dict = {"single": [], "multi": [], "score": []}
530
-
531
- st.sidebar.subheader("Main")
532
- main_dict["single"] = st.sidebar.multiselect(
533
- 'Main: Single answer questions',
534
- cols,
535
- default=[]
536
- )
537
-
538
- main_dict["multi"] = st.sidebar.multiselect(
539
- 'Main: Multi answer questions',
540
- cols,
541
- default=[]
542
- )
543
-
544
- main_dict["score"] = st.sidebar.multiselect(
545
- 'Main: Score answer questions',
546
- cols,
547
- default=[]
548
- )
549
-
550
- st.sidebar.subheader("Follow")
551
-
552
- follow_dict = {"single": [], "multi": [], "score": []}
553
-
554
- st.sidebar.subheader("Main")
555
- follow_dict["single"] = st.sidebar.multiselect(
556
- 'Follow: Single answer questions',
557
- cols,
558
- default=[]
559
- )
560
-
561
- follow_dict["multi"] = st.sidebar.multiselect(
562
- 'Follow: Multi answer questions',
563
- cols,
564
- default=[]
565
- )
566
 
567
- follow_dict["score"] = st.sidebar.multiselect(
568
- 'Follow: Score answer questions',
569
- cols,
570
- default=[]
571
- )
572
-
573
- all_tabulation(df, main_dict, follow_dict)
574
-
575
- elif tabulation_option == "Univariate":
576
- uni_option = st.selectbox("Select the type of univariate analysis:", ["Multiple answer", "Single answer", "Score answer"])
577
-
578
- if uni_option == "Single answer":
579
- var = st.text_input("Please enter the name of the desired column:")
580
- if var:
581
- if var in df.columns:
582
- result_df = single_answer(df[var])
583
- st.subheader("Univariate Analysis Results")
584
- st.dataframe(result_df)
585
-
586
- fig = figo('Bar', result_df["Percentage"][:-1, ], title='Percentage Histogram', xlabel=var, ylabel='Percentage', colorscale='Plotly3')
587
- st.plotly_chart(fig, use_container_width=True)
588
- else:
589
- st.error("The entered column was not found.")
590
- elif uni_option == "Multiple answer":
591
- var = st.text_input("Please enter the name of the desired column:")
592
- if var:
593
- matching_cols = [col for col in df.columns if is_matching_pattern(col, var)]
594
- if matching_cols:
595
- subset_df = df[matching_cols]
596
- result_df = multi_answer(subset_df)
597
-
598
- st.subheader("Multiple Answer Analysis Results")
599
- st.dataframe(result_df)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
600
 
601
- fig = figo('Bar', result_df["Percentage"][:-1], title='Percentage Histogram', xlabel=var, ylabel='Percentage', colorscale='Plotly3')
602
- st.plotly_chart(fig, use_container_width=True)
603
- else:
604
- st.error("No columns matching the entered pattern were found.")
605
-
606
- elif uni_option == "Score answer":
607
- var = st.text_input("Please enter the name of the desired column:")
608
- if var:
609
- subset_df = df[var]
610
- result_df = score_answer(subset_df)
611
-
612
- st.subheader("Score Answer Analysis Results")
613
  st.dataframe(result_df)
614
 
615
- fig = figo('Bar', result_df["Percentage"][:-2], title='Percentage Histogram', xlabel=var, ylabel='Percentage', colorscale='Plotly3')
616
  st.plotly_chart(fig, use_container_width=True)
617
  else:
618
  st.error("No columns matching the entered pattern were found.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
619
 
620
- elif tabulation_option == "Multivariate":
621
- st.subheader("Multivariate Analysis")
622
- var1 = st.text_input("Please enter the name of the first column:")
623
- var2 = st.text_input("Please enter the name of the second column:")
624
-
625
- if var1 and var2:
626
- type1 = st.selectbox("Select the type of analysis for the first column:", ["Multiple answer", "Single answer"], key='type1')
627
- type2 = st.selectbox("Select the type of analysis for the second column:", ["Multiple answer", "Single answer", "Score answer"], key='type2')
628
-
629
- if type1 == "Single answer" and type2 == "Single answer":
630
- percentile_df, frequency_df = two_variable_ss(df[[var1, var2]], var1, var2)
631
  st.subheader("Percentage Table")
632
  st.write(z_test_data(percentile_df))
633
-
634
  st.subheader("Frequency Table")
635
  st.dataframe(frequency_df)
636
-
637
  row, col = df.shape
638
  fig = figo('Scatter', percentile_df.iloc[:-1,:], title='Percentage Scatter plot', width=(col*5)+5, height=(row*25) + 10)
639
  st.plotly_chart(fig, use_container_width=True)
640
-
641
- elif type1 == "Single answer" and type2 == "Multiple answer":
642
- matching_cols = [col for col in df.columns if is_matching_pattern(col, var2)]
643
- if matching_cols:
644
- percentile_df, frequency_df = two_variable_sm(df[[var1] + matching_cols], var1, matching_cols)
645
- st.subheader("Percentage Table")
646
- st.write(z_test_data(percentile_df))
647
-
648
- st.subheader("Frequency Table")
649
- st.dataframe(frequency_df)
650
-
651
- row, col = df.shape
652
- fig = figo('Scatter', percentile_df.iloc[:-1,:], title='Percentage Scatter plot', width=(col*5)+5, height=(row*25) + 10)
653
- st.plotly_chart(fig, use_container_width=True)
654
-
655
- else:
656
- st.error("No columns matching the entered pattern were found.")
657
-
658
- elif type1 == "Multiple answer" and type2 == "Multiple answer":
659
- matching_cols1 = [col for col in df.columns if is_matching_pattern(col, var1)]
660
- matching_cols2 = [col for col in df.columns if is_matching_pattern(col, var2)]
661
- if matching_cols1 and matching_cols2:
662
- percentile_df, frequency_df = two_variable_mm(df[matching_cols1 + matching_cols2], matching_cols1, matching_cols2)
663
- st.subheader("Percentage Table")
664
- st.write(z_test_data(percentile_df))
665
-
666
- st.subheader("Frequency Table")
667
- st.dataframe(frequency_df)
668
-
669
- row, col = df.shape
670
- fig = figo('Scatter', percentile_df.iloc[:-1,:], title='Percentage Scatter plot', width=(col*5)+5, height=(row*25) + 10)
671
- st.plotly_chart(fig, use_container_width=True)
672
-
673
- elif type1 == "Single answer" and type2 == "Score answer":
674
-
675
- mean_df = two_variable_ssc(df[[var1, var2]], var1, var2)
676
  st.subheader("Mean Table")
677
  st.write(t_test_data(mean_df))
678
-
679
  row, col = df.shape
680
  fig = figo('Bar', mean_df["Mean"][:-1], title='Mean Histogram', xlabel=var1, ylabel='Mean', colorscale='Plotly3')
681
- st.plotly_chart(fig, use_container_width=True)
682
-
683
-
684
- elif type1 == "Multiple answer" and type2 == "Score answer":
685
- matching_cols1 = [col for col in df.columns if is_matching_pattern(col, var1)]
686
- if matching_cols1:
687
- mean_df = two_variable_msc(df[matching_cols1 + [var2]], matching_cols1, var2)
688
- st.subheader("Mean Table")
689
- st.write(t_test_data(mean_df))
690
-
691
- row, col = df.shape
692
- fig = figo('Bar', mean_df["Mean"][:-1], title='Mean Histogram', xlabel=var1, ylabel='Mean', colorscale='Plotly3')
693
- st.plotly_chart(fig, use_container_width=True)
694
- else:
695
- st.info("This section of the program is under development.")
696
 
697
  elif main_option == "Funnel":
698
  st.header("Funnel")
 
517
  if main_option == "Tabulation":
518
  st.header("Tabulation Analysis")
519
 
520
+ tabulation_option = st.selectbox("Please select the type of analysis:", ["Univariate", "Multivariate", "All"])
521
+
522
+ if tabulation_option == "All":
523
+
524
+ cols = edit_strings(df.columns)
525
+ cols = sorted(list(set(cols)))
526
+
527
+ st.sidebar.header("Settings")
528
+
529
+ main_dict = {"single": [], "multi": [], "score": []}
530
+
531
+ st.sidebar.subheader("Main")
532
+ main_dict["single"] = st.sidebar.multiselect(
533
+ 'Main: Single answer questions',
534
+ cols,
535
+ default=[]
536
+ )
537
+
538
+ main_dict["multi"] = st.sidebar.multiselect(
539
+ 'Main: Multi answer questions',
540
+ cols,
541
+ default=[]
542
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
543
 
544
+ main_dict["score"] = st.sidebar.multiselect(
545
+ 'Main: Score answer questions',
546
+ cols,
547
+ default=[]
548
+ )
549
+
550
+ st.sidebar.subheader("Follow")
551
+
552
+ follow_dict = {"single": [], "multi": [], "score": []}
553
+
554
+ st.sidebar.subheader("Main")
555
+ follow_dict["single"] = st.sidebar.multiselect(
556
+ 'Follow: Single answer questions',
557
+ cols,
558
+ default=[]
559
+ )
560
+
561
+ follow_dict["multi"] = st.sidebar.multiselect(
562
+ 'Follow: Multi answer questions',
563
+ cols,
564
+ default=[]
565
+ )
566
+
567
+ follow_dict["score"] = st.sidebar.multiselect(
568
+ 'Follow: Score answer questions',
569
+ cols,
570
+ default=[]
571
+ )
572
+
573
+ all_tabulation(df, main_dict, follow_dict)
574
+
575
+ elif tabulation_option == "Univariate":
576
+ uni_option = st.selectbox("Select the type of univariate analysis:", ["Multiple answer", "Single answer", "Score answer"])
577
+
578
+ if uni_option == "Single answer":
579
+ var = st.text_input("Please enter the name of the desired column:")
580
+ if var:
581
+ if var in df.columns:
582
+ result_df = single_answer(df[var])
583
+ st.subheader("Univariate Analysis Results")
584
+ st.dataframe(result_df)
585
+
586
+ fig = figo('Bar', result_df["Percentage"][:-1, ], title='Percentage Histogram', xlabel=var, ylabel='Percentage', colorscale='Plotly3')
587
+ st.plotly_chart(fig, use_container_width=True)
588
+ else:
589
+ st.error("The entered column was not found.")
590
+ elif uni_option == "Multiple answer":
591
+ var = st.text_input("Please enter the name of the desired column:")
592
+ if var:
593
+ matching_cols = [col for col in df.columns if is_matching_pattern(col, var)]
594
+ if matching_cols:
595
+ subset_df = df[matching_cols]
596
+ result_df = multi_answer(subset_df)
597
 
598
+ st.subheader("Multiple Answer Analysis Results")
 
 
 
 
 
 
 
 
 
 
 
599
  st.dataframe(result_df)
600
 
601
+ fig = figo('Bar', result_df["Percentage"][:-1], title='Percentage Histogram', xlabel=var, ylabel='Percentage', colorscale='Plotly3')
602
  st.plotly_chart(fig, use_container_width=True)
603
  else:
604
  st.error("No columns matching the entered pattern were found.")
605
+
606
+ elif uni_option == "Score answer":
607
+ var = st.text_input("Please enter the name of the desired column:")
608
+ if var:
609
+ subset_df = df[var]
610
+ result_df = score_answer(subset_df)
611
+
612
+ st.subheader("Score Answer Analysis Results")
613
+ st.dataframe(result_df)
614
+
615
+ fig = figo('Bar', result_df["Percentage"][:-2], title='Percentage Histogram', xlabel=var, ylabel='Percentage', colorscale='Plotly3')
616
+ st.plotly_chart(fig, use_container_width=True)
617
+ else:
618
+ st.error("No columns matching the entered pattern were found.")
619
+
620
+ elif tabulation_option == "Multivariate":
621
+ st.subheader("Multivariate Analysis")
622
+ var1 = st.text_input("Please enter the name of the first column:")
623
+ var2 = st.text_input("Please enter the name of the second column:")
624
+
625
+ if var1 and var2:
626
+ type1 = st.selectbox("Select the type of analysis for the first column:", ["Multiple answer", "Single answer"], key='type1')
627
+ type2 = st.selectbox("Select the type of analysis for the second column:", ["Multiple answer", "Single answer", "Score answer"], key='type2')
628
+
629
+ if type1 == "Single answer" and type2 == "Single answer":
630
+ percentile_df, frequency_df = two_variable_ss(df[[var1, var2]], var1, var2)
631
+ st.subheader("Percentage Table")
632
+ st.write(z_test_data(percentile_df))
633
+
634
+ st.subheader("Frequency Table")
635
+ st.dataframe(frequency_df)
636
+
637
+ row, col = df.shape
638
+ fig = figo('Scatter', percentile_df.iloc[:-1,:], title='Percentage Scatter plot', width=(col*5)+5, height=(row*25) + 10)
639
+ st.plotly_chart(fig, use_container_width=True)
640
+
641
+ elif type1 == "Single answer" and type2 == "Multiple answer":
642
+ matching_cols = [col for col in df.columns if is_matching_pattern(col, var2)]
643
+ if matching_cols:
644
+ percentile_df, frequency_df = two_variable_sm(df[[var1] + matching_cols], var1, matching_cols)
645
+ st.subheader("Percentage Table")
646
+ st.write(z_test_data(percentile_df))
647
+
648
+ st.subheader("Frequency Table")
649
+ st.dataframe(frequency_df)
650
+
651
+ row, col = df.shape
652
+ fig = figo('Scatter', percentile_df.iloc[:-1,:], title='Percentage Scatter plot', width=(col*5)+5, height=(row*25) + 10)
653
+ st.plotly_chart(fig, use_container_width=True)
654
 
655
+ else:
656
+ st.error("No columns matching the entered pattern were found.")
657
+
658
+ elif type1 == "Multiple answer" and type2 == "Multiple answer":
659
+ matching_cols1 = [col for col in df.columns if is_matching_pattern(col, var1)]
660
+ matching_cols2 = [col for col in df.columns if is_matching_pattern(col, var2)]
661
+ if matching_cols1 and matching_cols2:
662
+ percentile_df, frequency_df = two_variable_mm(df[matching_cols1 + matching_cols2], matching_cols1, matching_cols2)
 
 
 
663
  st.subheader("Percentage Table")
664
  st.write(z_test_data(percentile_df))
665
+
666
  st.subheader("Frequency Table")
667
  st.dataframe(frequency_df)
668
+
669
  row, col = df.shape
670
  fig = figo('Scatter', percentile_df.iloc[:-1,:], title='Percentage Scatter plot', width=(col*5)+5, height=(row*25) + 10)
671
  st.plotly_chart(fig, use_container_width=True)
672
+
673
+ elif type1 == "Single answer" and type2 == "Score answer":
674
+
675
+ mean_df = two_variable_ssc(df[[var1, var2]], var1, var2)
676
+ st.subheader("Mean Table")
677
+ st.write(t_test_data(mean_df))
678
+
679
+ row, col = df.shape
680
+ fig = figo('Bar', mean_df["Mean"][:-1], title='Mean Histogram', xlabel=var1, ylabel='Mean', colorscale='Plotly3')
681
+ st.plotly_chart(fig, use_container_width=True)
682
+
683
+
684
+ elif type1 == "Multiple answer" and type2 == "Score answer":
685
+ matching_cols1 = [col for col in df.columns if is_matching_pattern(col, var1)]
686
+ if matching_cols1:
687
+ mean_df = two_variable_msc(df[matching_cols1 + [var2]], matching_cols1, var2)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
688
  st.subheader("Mean Table")
689
  st.write(t_test_data(mean_df))
690
+
691
  row, col = df.shape
692
  fig = figo('Bar', mean_df["Mean"][:-1], title='Mean Histogram', xlabel=var1, ylabel='Mean', colorscale='Plotly3')
693
+ st.plotly_chart(fig, use_container_width=True)
694
+ else:
695
+ st.info("This section of the program is under development.")
 
 
 
 
 
 
 
 
 
 
 
 
696
 
697
  elif main_option == "Funnel":
698
  st.header("Funnel")