Allow the user to specify a statistical test. e.g.
# imports
from tableone import TableOne
from scipy import stats
import numpy as np
import pandas as pd
# create a sample dataset
np.random.seed(12345678)
n1 = 200
n2 = 300
# Baseline distribution
rvs1 = stats.norm.rvs(size=n1, loc=0., scale=1)
# Different to rvs1
rvs2 = stats.norm.rvs(size=n2, loc=0.5, scale=1.5)
# Combine values into a single DataFrame
df1 = pd.DataFrame({'rvs': 'rvs1', 'val': rvs1})
df2 = pd.DataFrame({'rvs': 'rvs2', 'val': rvs2})
different = df1.append(df2)
# define a custom test that takes a list of numpy array as an argument
# and that returns a test result
def mytest(*args):
mytest.__name__ = "BOING"
_, pval= stats.ks_2samp(*args)
return pval
Allow the user to specify a statistical test. e.g.