Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -117,6 +117,27 @@ def two_variable_sm(df, var1, var2):
|
|
117 |
percentage_dataframe.loc['Sample_size'] = list(single_answer(df[var1]).iloc[:,1])
|
118 |
|
119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
return percentage_dataframe, friquency_dataframe
|
121 |
|
122 |
# Functions related to Z-Test
|
@@ -298,6 +319,24 @@ if main_option == "Tabulation":
|
|
298 |
|
299 |
else:
|
300 |
st.error("No columns matching the entered pattern were found.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
else:
|
302 |
st.info("This section of the program is under development.")
|
303 |
|
|
|
117 |
percentage_dataframe.loc['Sample_size'] = list(single_answer(df[var1]).iloc[:,1])
|
118 |
|
119 |
|
120 |
+
return percentage_dataframe, friquency_dataframe
|
121 |
+
|
122 |
+
def two_variable_mm(df, var1, var2):
|
123 |
+
friquency_dataframe, percentage_dataframe = {}, {}
|
124 |
+
value = multi_answer(df[var2]).iloc[:-1,0]
|
125 |
+
|
126 |
+
for i in var1:
|
127 |
+
unique_values = list(set(df[i].dropna()))[0]
|
128 |
+
dataframe = multi_answer(df[df[i] == unique_values][var2]).iloc[:-1,:]
|
129 |
+
friquency_dataframe[i], percentage_dataframe[i] = dataframe['Friquency'], dataframe['Percentage']
|
130 |
+
|
131 |
+
friquency_dataframe = pd.DataFrame(friquency_dataframe)
|
132 |
+
percentage_dataframe = pd.DataFrame(percentage_dataframe)
|
133 |
+
|
134 |
+
friquency_dataframe.index, percentage_dataframe.index = value, value
|
135 |
+
|
136 |
+
friquency_dataframe['Total'] = list(multi_answer(df[var2]).iloc[:,1])[:-1]
|
137 |
+
friquency_dataframe.loc['Sample_size'] = list(multi_answer(df[var1]).iloc[:,1])
|
138 |
+
percentage_dataframe['Total'] = list(multi_answer(df[var2]).iloc[:,2])[:-1]
|
139 |
+
percentage_dataframe.loc['Sample_size'] = list(multi_answer(df[var1]).iloc[:,1])
|
140 |
+
|
141 |
return percentage_dataframe, friquency_dataframe
|
142 |
|
143 |
# Functions related to Z-Test
|
|
|
319 |
|
320 |
else:
|
321 |
st.error("No columns matching the entered pattern were found.")
|
322 |
+
|
323 |
+
elif type1 == "Multiple answer" and type2 == "Multiple answer":
|
324 |
+
matching_cols1 = [col for col in df.columns if is_matching_pattern(col, var1)]
|
325 |
+
matching_cols2 = [col for col in df.columns if is_matching_pattern(col, var2)]
|
326 |
+
if matching_cols1 and matching_cols2:
|
327 |
+
percentile_df, frequency_df = two_variable_mm(df[matching_cols1 + matching_cols2], matching_cols1, matching_cols2)
|
328 |
+
st.subheader("Percentage Table")
|
329 |
+
st.dataframe(percentile_df)
|
330 |
+
|
331 |
+
st.subheader("Frequency Table")
|
332 |
+
st.dataframe(frequency_df)
|
333 |
+
|
334 |
+
fig = figo('Heatmap', percentile_df.iloc[:-1,:-1], title='Percentage Histogram', xlabel=var1, ylabel=var2, colorscale='Plotly3')
|
335 |
+
st.plotly_chart(fig, use_container_width=True)
|
336 |
+
|
337 |
+
else:
|
338 |
+
st.error("No columns matching the entered pattern were found.")
|
339 |
+
|
340 |
else:
|
341 |
st.info("This section of the program is under development.")
|
342 |
|