from scipy.stats import chi2_contingency as chi2 import numpy as np obs = np.array([[2887.0, 459.0], [61.0, 383.0]]) chi,p,dof,expected = chi2(obs) print("%f, %e, %f" % (chi, p, dof)) ''' survive: chi = 1189.53, p = 1.149752e-260 survive: chi = 611.59, p = 5.031232e-135 '''