You are on page 1of 1

import pandas as pd

from scipy.stats import ttest_ind

# Load the dataframe


df = pd.read_csv("data.csv")

# Extract the two samples from the dataframe


sample1 = df["sample1"].values
sample2 = df["sample2"].values

# Calculate the p-value


_, pval = ttest_ind(sample1, sample2)

# Add the p-value to the dataframe as a new column


df["pval"] = pval

# Print the updated dataframe


print(df)

-----------------------------------------------------------------------------------
--------------------------
import pandas as pd
from statsmodels.stats.multitest import multipletests

# Load the dataframe


df = pd.read_csv("data.csv")

# Extract the p-values from the dataframe


pvals = df["pval"].values

# Perform multiplicity correction on the p-values


reject, pvals_corrected, _, _ = multipletests(pvals, alpha=0.05,
method='bonferroni')

# Add the corrected p-values and hypothesis test results to the dataframe
df["pval_corrected"] = pvals_corrected
df["reject"] = reject

# Print the updated dataframe


print(df)

You might also like