In [11]:
from scipy.stats import chi2_contingency
import numpy as np

In [13]:
obs = np.array([[7, 87, 12,9], [4, 102, 7,8]])

In [15]:
chi2, p, dof, expected = chi2_contingency(obs)

In [16]:
print (p)


0.357103080041

In [17]:
print (chi2)


3.23281822261

In [18]:
print (dof)


3

In [19]:
print (expected)


[[  5.36016949  92.09745763   9.25847458   8.28389831]
 [  5.63983051  96.90254237   9.74152542   8.71610169]]

In [ ]: