Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ import pandas as pd
|
|
3 |
import numpy as np
|
4 |
import plotly.express as px
|
5 |
import plotly.graph_objects as go
|
6 |
-
from scipy.stats import norm
|
7 |
|
8 |
def sorting(df):
|
9 |
df.index = list(map(float, df.index))
|
@@ -233,16 +233,10 @@ def two_variable_msc(df, var1, var2):
|
|
233 |
|
234 |
return mean_dataframe
|
235 |
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
xls = pd.ExcelFile(file)
|
241 |
-
sheets_data = {sheet: xls.parse(sheet) for sheet in xls.sheet_names}
|
242 |
-
return sheets_data
|
243 |
-
except Exception as e:
|
244 |
-
st.error(f"❌ Error reading Excel file: {e}")
|
245 |
-
return None
|
246 |
|
247 |
def z_testes(n1, n2, p1, p2):
|
248 |
p_hat = ((n1*p1) + (n2*p2)) / (n1 + n2)
|
@@ -268,6 +262,17 @@ def z_test_data(df):
|
|
268 |
|
269 |
return df.style.apply(lambda _: styles, axis=None)
|
270 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
271 |
def Z_test_dataframes(sheets_data):
|
272 |
"""Processes each sheet's DataFrame and computes new DataFrames with Z-test results."""
|
273 |
result_dataframes = {}
|
@@ -471,7 +476,7 @@ if main_option == "Tabulation":
|
|
471 |
|
472 |
elif type1 == "Multiple answer" and type2 == "Score answer":
|
473 |
matching_cols1 = [col for col in df.columns if is_matching_pattern(col, var1)]
|
474 |
-
if matching_cols1
|
475 |
percentile_df, frequency_df = two_variable_mm(df[matching_cols1 + [var2]], matching_cols1, var2)
|
476 |
st.subheader("Mean Table")
|
477 |
st.write(mean_df)
|
|
|
3 |
import numpy as np
|
4 |
import plotly.express as px
|
5 |
import plotly.graph_objects as go
|
6 |
+
from scipy.stats import norm, t
|
7 |
|
8 |
def sorting(df):
|
9 |
df.index = list(map(float, df.index))
|
|
|
233 |
|
234 |
return mean_dataframe
|
235 |
|
236 |
+
def t_test(m1, m2, n1, n2, v1, v2):
|
237 |
+
t = (m1 - m2) / ((v1/n1 + v2/n2)**0.5)
|
238 |
+
p_value = 2 * (1 - t.cdf(abs(t)))
|
239 |
+
return p_value
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
|
241 |
def z_testes(n1, n2, p1, p2):
|
242 |
p_hat = ((n1*p1) + (n2*p2)) / (n1 + n2)
|
|
|
262 |
|
263 |
return df.style.apply(lambda _: styles, axis=None)
|
264 |
|
265 |
+
# Functions related to Z-Test
|
266 |
+
def read_excel_sheets(file):
|
267 |
+
"""Reads an Excel file with multiple sheets and returns a dictionary of DataFrames."""
|
268 |
+
try:
|
269 |
+
xls = pd.ExcelFile(file)
|
270 |
+
sheets_data = {sheet: xls.parse(sheet) for sheet in xls.sheet_names}
|
271 |
+
return sheets_data
|
272 |
+
except Exception as e:
|
273 |
+
st.error(f"❌ Error reading Excel file: {e}")
|
274 |
+
return None
|
275 |
+
|
276 |
def Z_test_dataframes(sheets_data):
|
277 |
"""Processes each sheet's DataFrame and computes new DataFrames with Z-test results."""
|
278 |
result_dataframes = {}
|
|
|
476 |
|
477 |
elif type1 == "Multiple answer" and type2 == "Score answer":
|
478 |
matching_cols1 = [col for col in df.columns if is_matching_pattern(col, var1)]
|
479 |
+
if matching_cols1:
|
480 |
percentile_df, frequency_df = two_variable_mm(df[matching_cols1 + [var2]], matching_cols1, var2)
|
481 |
st.subheader("Mean Table")
|
482 |
st.write(mean_df)
|