본문 바로가기

언어 꿀Tip/Python 꿀tip!

07_07_43. chi-square test (카이제곱 검정)

import pandas as pd
from scipy.stats import chisquare
import scipy.stats as stats

# df라는 데이터프레임에 x7_2, x5라는 변수가 존재한다고 했을 때!
result_31=pd.crosstab(df.x7_2, df.x5)
result_31_chi, p, dof, ex = stats.chi2_contingency(observed=result_31)

# p : p-value

chi-square test