AMKhakbaz commited on
Commit
335d6f5
·
verified ·
1 Parent(s): 1cbab06

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -38
app.py CHANGED
@@ -760,6 +760,7 @@ try:
760
  st.dataframe(funnel_frequency)
761
 
762
  st.sidebar.header("Chart Settings")
 
763
  bar_columns = st.sidebar.multiselect('Which columns should be displayed as bar charts?', sorted(funnel_percentage.columns))
764
  line_columns = st.sidebar.multiselect('Which columns should be displayed as line charts?', sorted(funnel_percentage.columns))
765
 
@@ -772,6 +773,9 @@ try:
772
  ascending = True if sort_order == 'Ascending' else False
773
  funnel_percentage_cleaned = funnel_percentage_cleaned.sort_values(by=columns, ascending=ascending)
774
 
 
 
 
775
  fig = go.Figure()
776
 
777
  # Define modern and diverse color palette
@@ -813,49 +817,16 @@ try:
813
  yaxis_title="Percentage",
814
  template="plotly_dark",
815
  barmode="group",
816
- xaxis=dict(tickmode='array', categoryorder='array', categoryarray=funnel_percentage_cleaned.index.tolist())
 
 
 
 
817
  )
818
 
819
  st.plotly_chart(fig)
820
 
821
 
822
- elif main_option == "Segmentation Analysis":
823
- st.header("Segmentation Analysis")
824
-
825
- st.sidebar.header("Selection of questions")
826
- single_list = st.sidebar.multiselect(
827
- 'Single answer questions',
828
- cols,
829
- default=[]
830
- )
831
-
832
- multi_list = st.sidebar.multiselect(
833
- 'Multi answer questions',
834
- cols,
835
- default=[]
836
- )
837
-
838
- score_list = st.sidebar.multiselect(
839
- 'Score answer questions',
840
- cols,
841
- default=[]
842
- )
843
-
844
- matching_cols1 = []
845
- for i in multi_list:
846
- matching_cols1 += [col for col in df.columns if is_matching_pattern(col, i)]
847
-
848
- df_clean = process_dataframe(df[single_list + matching_cols1])
849
- st.subheader("Selected Table")
850
- st.dataframe(df_clean)
851
-
852
- linkage_method = st.sidebar.selectbox("Select the Linkage Method of Segmentation Analysis:", ['average', 'single', 'complete', 'weighted', 'centroid', 'median', 'ward'])
853
-
854
- df_cluster = hierarchical_clustering_with_plotly(df_clean, linkage_method)
855
-
856
- st.subheader("Cluster Table")
857
- st.dataframe(df_clean)
858
-
859
  elif main_option == "Hypothesis test":
860
  st.header("Hypothesis Testing")
861
  hypothesis_option = st.selectbox("Please select the type of hypothesis test:", ["Z test", "T test", "Chi-Square test", "ANOVA test"])
 
760
  st.dataframe(funnel_frequency)
761
 
762
  st.sidebar.header("Chart Settings")
763
+
764
  bar_columns = st.sidebar.multiselect('Which columns should be displayed as bar charts?', sorted(funnel_percentage.columns))
765
  line_columns = st.sidebar.multiselect('Which columns should be displayed as line charts?', sorted(funnel_percentage.columns))
766
 
 
773
  ascending = True if sort_order == 'Ascending' else False
774
  funnel_percentage_cleaned = funnel_percentage_cleaned.sort_values(by=columns, ascending=ascending)
775
 
776
+ # Update index to string to ensure proper sorting in Plotly
777
+ funnel_percentage_cleaned.index = funnel_percentage_cleaned.index.astype(str)
778
+
779
  fig = go.Figure()
780
 
781
  # Define modern and diverse color palette
 
817
  yaxis_title="Percentage",
818
  template="plotly_dark",
819
  barmode="group",
820
+ xaxis=dict(
821
+ tickmode='array',
822
+ categoryorder='array',
823
+ categoryarray=funnel_percentage_cleaned.index.tolist() # Ensure sorting of x-axis matches the DataFrame index
824
+ )
825
  )
826
 
827
  st.plotly_chart(fig)
828
 
829
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
830
  elif main_option == "Hypothesis test":
831
  st.header("Hypothesis Testing")
832
  hypothesis_option = st.selectbox("Please select the type of hypothesis test:", ["Z test", "T test", "Chi-Square test", "ANOVA test"])