import pandas as pd import numpy as np #import scipy.stats as stats #from scipy.stats import chi2 from scipy.stats.distributions import t as tdist df = 10 t_1 = np.empty(df) t_2 = np.empty(df) t_3 = np.empty(df) t_4 = np.empty(df) t_5 = np.empty(df) # repeat r times: for j in range(df): t_1[j] = tdist.ppf(0.9, df=j) j=j+1 for j in range(df): t_2[j] = tdist.ppf(0.95, df=j) j=j+1 for j in range(df): t_3[j] = tdist.ppf(0.975, df=j) j=j+1 for j in range(df): t_4[j] = tdist.ppf(0.99, df=j) j=j+1 for j in range(df): t_5[j] = tdist.ppf(0.995, df=j) j=j+1 t_dist = pd.DataFrame({'p=0.1':t_1,'p=0.05':t_2,'p=0.025':t_3,'p=0.01':t_4,'p=0.005':t_5}) t = t_dist.dropna(how='all') # to drop if all values in the row are NaN round(t, 3) print("t Distribution Table with 'p=0.9, ..., p=0.995' : ", f'\n{round(t, 3)}\n')