Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -506,294 +506,294 @@ st.markdown('[Click to register a suggestion or comment](https://docs.google.com
|
|
506 |
# Main options
|
507 |
|
508 |
uploaded_file = st.file_uploader("Please upload your Excel file", type=["xlsx", "xls"])
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
|
515 |
-
|
516 |
-
|
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 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
600 |
|
601 |
-
|
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"][:-
|
616 |
st.plotly_chart(fig, use_container_width=True)
|
617 |
else:
|
618 |
st.error("No columns matching the entered pattern were found.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
619 |
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
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 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
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 |
-
|
685 |
-
|
686 |
-
|
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 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
696 |
|
697 |
-
|
698 |
-
st.header("Funnel")
|
699 |
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
selected_dict[option] = "Single"
|
719 |
-
for option in multi_list:
|
720 |
-
selected_dict[option] = "Multi"
|
721 |
-
|
722 |
-
funnel_frequency, funnel_percentage = funnel(df, selected_dict)
|
723 |
-
st.subheader("Percentage Table")
|
724 |
-
st.dataframe(funnel_percentage)
|
725 |
-
|
726 |
-
st.subheader("Frequency Table")
|
727 |
-
st.dataframe(funnel_frequency)
|
728 |
-
|
729 |
-
st.sidebar.header("Chart Settings")
|
730 |
-
bar_columns = st.sidebar.multiselect('Which columns should be displayed as bar charts?', sorted(funnel_percentage.columns))
|
731 |
-
line_columns = st.sidebar.multiselect('Which columns should be displayed as line charts?', sorted(funnel_percentage.columns))
|
732 |
-
|
733 |
-
funnel_percentage_cleaned = funnel_percentage.dropna(axis=0, how='all')
|
734 |
-
|
735 |
-
fig = go.Figure()
|
736 |
-
|
737 |
-
# Define modern and diverse color palette
|
738 |
-
modern_colors = [
|
739 |
-
"#FF6F61", "#6B5B95", "#88B04B", "#F7CAC9", "#92A8D1",
|
740 |
-
"#955251", "#B565A7", "#009B77", "#DD4124", "#45B8AC"
|
741 |
-
]
|
742 |
-
|
743 |
-
# Add Bar traces with transparency and custom colors
|
744 |
-
for idx, col in enumerate(bar_columns):
|
745 |
-
funnel_percentage_col = funnel_percentage_cleaned[col]
|
746 |
-
fig.add_trace(
|
747 |
-
go.Bar(
|
748 |
-
x=funnel_percentage_cleaned.index,
|
749 |
-
y=funnel_percentage_col,
|
750 |
-
name=col,
|
751 |
-
marker_color=modern_colors[idx % len(modern_colors)], # Cycle through colors
|
752 |
-
opacity=0.8 # Set transparency
|
753 |
-
)
|
754 |
-
)
|
755 |
-
|
756 |
-
# Add Line traces with transparency and custom colors
|
757 |
-
for idx, col in enumerate(line_columns):
|
758 |
-
funnel_percentage_col = funnel_percentage_cleaned[col]
|
759 |
-
fig.add_trace(
|
760 |
-
go.Scatter(
|
761 |
-
x=funnel_percentage_cleaned.index,
|
762 |
-
y=funnel_percentage_col,
|
763 |
-
mode='lines',
|
764 |
-
name=col,
|
765 |
-
line=dict(color=modern_colors[(idx + len(bar_columns)) % len(modern_colors)]), # Cycle through colors
|
766 |
-
opacity=0.8 # Set transparency
|
767 |
-
)
|
768 |
)
|
769 |
-
|
770 |
-
fig.update_layout(
|
771 |
-
title="Combined Bar and Line Chart",
|
772 |
-
xaxis_title="Brands",
|
773 |
-
yaxis_title="Percentage",
|
774 |
-
template="plotly_dark",
|
775 |
-
barmode="group",
|
776 |
-
xaxis=dict(tickmode='linear')
|
777 |
)
|
778 |
-
|
779 |
-
st.plotly_chart(fig)
|
780 |
-
|
781 |
-
|
782 |
-
elif main_option == "Hypothesis test":
|
783 |
-
st.header("Hypothesis Testing")
|
784 |
-
hypothesis_option = st.selectbox("Please select the type of hypothesis test:", ["Z test", "T test", "Chi-Square test", "ANOVA test"])
|
785 |
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
794 |
|
795 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
796 |
st.info("This section of the program is under development.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
797 |
|
798 |
-
|
799 |
-
|
|
|
506 |
# Main options
|
507 |
|
508 |
uploaded_file = st.file_uploader("Please upload your Excel file", type=["xlsx", "xls"])
|
509 |
+
if uploaded_file:
|
510 |
+
try:
|
511 |
+
df = pd.read_excel(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")
|
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")
|
|
|
|
|
|
|
699 |
|
700 |
+
cols = edit_strings(df.columns)
|
701 |
+
cols = sorted(list(set(cols)))
|
702 |
+
|
703 |
+
st.sidebar.header("Funnel Settings")
|
704 |
+
single_list = st.sidebar.multiselect(
|
705 |
+
'Single answer questions',
|
706 |
+
cols,
|
707 |
+
default=[]
|
708 |
+
)
|
709 |
+
|
710 |
+
multi_list = st.sidebar.multiselect(
|
711 |
+
'Multi answer questions',
|
712 |
+
cols,
|
713 |
+
default=[]
|
714 |
+
)
|
715 |
+
selected_dict = {}
|
716 |
+
|
717 |
+
for option in single_list:
|
718 |
+
selected_dict[option] = "Single"
|
719 |
+
for option in multi_list:
|
720 |
+
selected_dict[option] = "Multi"
|
721 |
+
|
722 |
+
funnel_frequency, funnel_percentage = funnel(df, selected_dict)
|
723 |
+
st.subheader("Percentage Table")
|
724 |
+
st.dataframe(funnel_percentage)
|
725 |
+
|
726 |
+
st.subheader("Frequency Table")
|
727 |
+
st.dataframe(funnel_frequency)
|
728 |
+
|
729 |
+
st.sidebar.header("Chart Settings")
|
730 |
+
bar_columns = st.sidebar.multiselect('Which columns should be displayed as bar charts?', sorted(funnel_percentage.columns))
|
731 |
+
line_columns = st.sidebar.multiselect('Which columns should be displayed as line charts?', sorted(funnel_percentage.columns))
|
732 |
|
733 |
+
funnel_percentage_cleaned = funnel_percentage.dropna(axis=0, how='all')
|
|
|
734 |
|
735 |
+
fig = go.Figure()
|
736 |
+
|
737 |
+
# Define modern and diverse color palette
|
738 |
+
modern_colors = [
|
739 |
+
"#FF6F61", "#6B5B95", "#88B04B", "#F7CAC9", "#92A8D1",
|
740 |
+
"#955251", "#B565A7", "#009B77", "#DD4124", "#45B8AC"
|
741 |
+
]
|
742 |
+
|
743 |
+
# Add Bar traces with transparency and custom colors
|
744 |
+
for idx, col in enumerate(bar_columns):
|
745 |
+
funnel_percentage_col = funnel_percentage_cleaned[col]
|
746 |
+
fig.add_trace(
|
747 |
+
go.Bar(
|
748 |
+
x=funnel_percentage_cleaned.index,
|
749 |
+
y=funnel_percentage_col,
|
750 |
+
name=col,
|
751 |
+
marker_color=modern_colors[idx % len(modern_colors)], # Cycle through colors
|
752 |
+
opacity=0.8 # Set transparency
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
753 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
754 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
755 |
|
756 |
+
# Add Line traces with transparency and custom colors
|
757 |
+
for idx, col in enumerate(line_columns):
|
758 |
+
funnel_percentage_col = funnel_percentage_cleaned[col]
|
759 |
+
fig.add_trace(
|
760 |
+
go.Scatter(
|
761 |
+
x=funnel_percentage_cleaned.index,
|
762 |
+
y=funnel_percentage_col,
|
763 |
+
mode='lines',
|
764 |
+
name=col,
|
765 |
+
line=dict(color=modern_colors[(idx + len(bar_columns)) % len(modern_colors)]), # Cycle through colors
|
766 |
+
opacity=0.8 # Set transparency
|
767 |
+
)
|
768 |
+
)
|
769 |
+
|
770 |
+
fig.update_layout(
|
771 |
+
title="Combined Bar and Line Chart",
|
772 |
+
xaxis_title="Brands",
|
773 |
+
yaxis_title="Percentage",
|
774 |
+
template="plotly_dark",
|
775 |
+
barmode="group",
|
776 |
+
xaxis=dict(tickmode='linear')
|
777 |
+
)
|
778 |
|
779 |
+
st.plotly_chart(fig)
|
780 |
+
|
781 |
+
|
782 |
+
elif main_option == "Hypothesis test":
|
783 |
+
st.header("Hypothesis Testing")
|
784 |
+
hypothesis_option = st.selectbox("Please select the type of hypothesis test:", ["Z test", "T test", "Chi-Square test", "ANOVA test"])
|
785 |
+
|
786 |
+
if hypothesis_option != "Z test":
|
787 |
st.info("This section of the program is under development.")
|
788 |
+
else:
|
789 |
+
uploaded_file = st.file_uploader("Please upload your Excel file for Z-Test", type=["xlsx", "xls"])
|
790 |
+
if uploaded_file:
|
791 |
+
result = analyze_z_test(uploaded_file)
|
792 |
+
if result:
|
793 |
+
st.success("Z-Test analysis completed successfully.")
|
794 |
+
|
795 |
+
elif main_option in ["Machine Learning", "Coding"]:
|
796 |
+
st.info("This section of the program is under development.")
|
797 |
|
798 |
+
except Exception as e:
|
799 |
+
st.error(f"❌ Error reading the Excel file: {e}")
|