For this chisq.test
call python equivalent is chi2_contingency
:
This function computes the chi-square statistic and p-value for the hypothesis test of independence of the observed frequencies in the contingency table observed.
>>> arr = np.array([38,27,23,17,11,4,98,100,80,85,60,23]).reshape(2,-1)
>>> arr
array([[ 38, 27, 23, 17, 11, 4],
[ 98, 100, 80, 85, 60, 23]])
>>> chi2, p, dof, expected = scipy.stats.chi2_contingency(arr)
>>> chi2, p, dof
(7.0762165124844367, 0.21503342516989818, 5)