Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -131,7 +131,7 @@ def multi_answer(df):
|
|
131 |
unique_values = list(set(df[i].dropna()))[0]
|
132 |
friquency[str(unique_values)] = df[i].value_counts().get(unique_values, 0)
|
133 |
except Exception as e:
|
134 |
-
st.error(f"Warning: One of the data columns has no value.: {e}")
|
135 |
friquency[i] = 0
|
136 |
|
137 |
|
@@ -411,6 +411,58 @@ def analyze_z_test(file):
|
|
411 |
return result_dataframes
|
412 |
|
413 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
414 |
empty_col1, main_col, empty_col2 = st.columns([1.6, 2.8, 1.6])
|
415 |
|
416 |
with main_col:
|
@@ -442,7 +494,58 @@ if main_option == "Tabulation":
|
|
442 |
tabulation_option = st.selectbox("Please select the type of analysis:", ["Univariate", "Multivariate", "All"])
|
443 |
|
444 |
if tabulation_option == "All":
|
445 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
446 |
elif tabulation_option == "Univariate":
|
447 |
uni_option = st.selectbox("Select the type of univariate analysis:", ["Multiple answer", "Single answer", "Score answer"])
|
448 |
|
|
|
131 |
unique_values = list(set(df[i].dropna()))[0]
|
132 |
friquency[str(unique_values)] = df[i].value_counts().get(unique_values, 0)
|
133 |
except Exception as e:
|
134 |
+
#st.error(f"Warning: One of the data columns has no value.: {e}")
|
135 |
friquency[i] = 0
|
136 |
|
137 |
|
|
|
411 |
return result_dataframes
|
412 |
|
413 |
|
414 |
+
def all_tabulation(df, main_dict, follow_dict):
|
415 |
+
|
416 |
+
for j in main_dict["single"]:
|
417 |
+
|
418 |
+
dataframe_list, name_list = (single_answer(df[j]),), [j]
|
419 |
+
|
420 |
+
for i in follow_dict["single"]:
|
421 |
+
dataframe_list = dataframe_list + (two_variable_ss(df[[j, i]], j, i)[0], )
|
422 |
+
name_list.append(i)
|
423 |
+
|
424 |
+
for i in follow_dict["multi"]:
|
425 |
+
matching_cols1 = [col for col in df.columns if is_matching_pattern(col, i)]
|
426 |
+
dataframe_list = dataframe_list + (two_variable_sm(df[[j] + matching_cols1], j, matching_cols1)[0], )
|
427 |
+
name_list.append(i)
|
428 |
+
|
429 |
+
for i in follow_dict["score"]:
|
430 |
+
dataframe_list = dataframe_list + (two_variable_ssc(df[[j, i]], j, i), )
|
431 |
+
name_list.append(i)
|
432 |
+
|
433 |
+
st.subheader(j)
|
434 |
+
st.markdown(j + ": " + ", ".join(follow_dict['single'] + follow_dict['multi'] + follow_dict['scor']))
|
435 |
+
st.dataframe(join_dataframes(name_list, dataframe_list))
|
436 |
+
|
437 |
+
for j in main_dict["multi"]:
|
438 |
+
|
439 |
+
matching_cols0 = [col for col in df.columns if is_matching_pattern(col, j)]
|
440 |
+
dataframe_list, name_list = (multi_answer(df[matching_cols0]), ), [j]
|
441 |
+
|
442 |
+
#for i in follow_dict["single"]:
|
443 |
+
#dataframe_list.append(two_variable_ms(df[matching_cols0, i], matching_cols0, i).drop(columns=['Value'])[0])
|
444 |
+
|
445 |
+
for i in follow_dict["multi"]:
|
446 |
+
matching_cols1 = [col for col in df.columns if is_matching_pattern(col, i)]
|
447 |
+
dataframe_list = dataframe_list + (two_variable_mm(df[matching_cols0 + matching_cols1], matching_cols0, matching_cols1)[0], )
|
448 |
+
name_list.append(i)
|
449 |
+
|
450 |
+
for i in follow_dict["score"]:
|
451 |
+
dataframe_list = dataframe_list + (two_variable_msc(df[matching_cols0 + [i]], matching_cols0, i), )
|
452 |
+
name_list.append(i)
|
453 |
+
|
454 |
+
st.subheader(j)
|
455 |
+
st.markdown(j + ": " + ", ".join(follow_dict['multi'] + follow_dict['scor']))
|
456 |
+
st.dataframe(join_dataframes(name_list, dataframe_list))
|
457 |
+
|
458 |
+
for j in main_dict["score"]:
|
459 |
+
|
460 |
+
dataframe_list, name_list = [single_answer(df[j])], [j]
|
461 |
+
|
462 |
+
st.subheader(j)
|
463 |
+
st.dataframe(join_dataframes(name_list, dataframe_list))
|
464 |
+
|
465 |
+
|
466 |
empty_col1, main_col, empty_col2 = st.columns([1.6, 2.8, 1.6])
|
467 |
|
468 |
with main_col:
|
|
|
494 |
tabulation_option = st.selectbox("Please select the type of analysis:", ["Univariate", "Multivariate", "All"])
|
495 |
|
496 |
if tabulation_option == "All":
|
497 |
+
|
498 |
+
cols = edit_strings(df.columns)
|
499 |
+
cols = sorted(list(set(cols)))
|
500 |
+
|
501 |
+
st.sidebar.header("Settings")
|
502 |
+
|
503 |
+
main_dict = {"single": [], "multi": [], "score": []}
|
504 |
+
|
505 |
+
st.sidebar.subheader("Main")
|
506 |
+
main_dict["single"] = st.sidebar.multiselect(
|
507 |
+
'Single answer questions',
|
508 |
+
cols,
|
509 |
+
default=[]
|
510 |
+
)
|
511 |
+
|
512 |
+
main_dict["multi"] = st.sidebar.multiselect(
|
513 |
+
'Multi answer questions',
|
514 |
+
cols,
|
515 |
+
default=[]
|
516 |
+
)
|
517 |
+
|
518 |
+
main_dict["score"] = st.sidebar.multiselect(
|
519 |
+
'Score answer questions',
|
520 |
+
cols,
|
521 |
+
default=[]
|
522 |
+
)
|
523 |
+
|
524 |
+
st.sidebar.subheader("Follow")
|
525 |
+
|
526 |
+
follow_dict = {"single": [], "multi": [], "score": []}
|
527 |
+
|
528 |
+
st.sidebar.subheader("Main")
|
529 |
+
follow_dict["single"] = st.sidebar.multiselect(
|
530 |
+
'Single answer questions',
|
531 |
+
cols,
|
532 |
+
default=[]
|
533 |
+
)
|
534 |
+
|
535 |
+
follow_dict["multi"] = st.sidebar.multiselect(
|
536 |
+
'Multi answer questions',
|
537 |
+
cols,
|
538 |
+
default=[]
|
539 |
+
)
|
540 |
+
|
541 |
+
follow_dict["score"] = st.sidebar.multiselect(
|
542 |
+
'Score answer questions',
|
543 |
+
cols,
|
544 |
+
default=[]
|
545 |
+
)
|
546 |
+
|
547 |
+
all_tabulation(df, main_dict, follow_dict)
|
548 |
+
|
549 |
elif tabulation_option == "Univariate":
|
550 |
uni_option = st.selectbox("Select the type of univariate analysis:", ["Multiple answer", "Single answer", "Score answer"])
|
551 |
|