Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -98,7 +98,7 @@ def two_variable_ss(df, var1, var2):
|
|
98 |
friquency_dataframe = counter.unstack(fill_value=0)
|
99 |
|
100 |
column_sums = friquency_dataframe.sum(axis=0)
|
101 |
-
percentage_dataframe = friquency_dataframe.div(column_sums, axis=1)
|
102 |
|
103 |
friquency_dataframe['Total'] = list(single_answer(df[var1]).iloc[:,1])[:-1]
|
104 |
friquency_dataframe.loc['Sample_size'] = list(single_answer(df[var2]).iloc[:,1])
|
@@ -175,6 +175,7 @@ def z_testes(n1, n2, p1, p2):
|
|
175 |
def z_test_data(df):
|
176 |
|
177 |
rows, cols = df.shape
|
|
|
178 |
|
179 |
for i in range(rows-2):
|
180 |
for j in range(cols-2):
|
@@ -183,12 +184,12 @@ def z_test_data(df):
|
|
183 |
p1 = df.iloc[i, -1] # x_1J
|
184 |
p2 = df.iloc[i, j] # x_ij
|
185 |
p_value = z_testes(n1, n2, p1, p2)
|
186 |
-
if p_value
|
187 |
-
|
188 |
else:
|
189 |
-
|
190 |
|
191 |
-
return df
|
192 |
|
193 |
def Z_test_dataframes(sheets_data):
|
194 |
"""Processes each sheet's DataFrame and computes new DataFrames with Z-test results."""
|
|
|
98 |
friquency_dataframe = counter.unstack(fill_value=0)
|
99 |
|
100 |
column_sums = friquency_dataframe.sum(axis=0)
|
101 |
+
percentage_dataframe = friquency_dataframe.div(column_sums, axis=1) * 100
|
102 |
|
103 |
friquency_dataframe['Total'] = list(single_answer(df[var1]).iloc[:,1])[:-1]
|
104 |
friquency_dataframe.loc['Sample_size'] = list(single_answer(df[var2]).iloc[:,1])
|
|
|
175 |
def z_test_data(df):
|
176 |
|
177 |
rows, cols = df.shape
|
178 |
+
styles = pd.DataFrame('', index=df.index, columns=df.columns)
|
179 |
|
180 |
for i in range(rows-2):
|
181 |
for j in range(cols-2):
|
|
|
184 |
p1 = df.iloc[i, -1] # x_1J
|
185 |
p2 = df.iloc[i, j] # x_ij
|
186 |
p_value = z_testes(n1, n2, p1, p2)
|
187 |
+
if p_value <= 0.05:
|
188 |
+
styles.iloc[i, j] = 'background-color: lightgreen;'
|
189 |
else:
|
190 |
+
styles.iloc[i, j] = 'background-color: lightgray;'
|
191 |
|
192 |
+
return df.style.apply(lambda x: styles, axis=None)
|
193 |
|
194 |
def Z_test_dataframes(sheets_data):
|
195 |
"""Processes each sheet's DataFrame and computes new DataFrames with Z-test results."""
|