p-value of chi squared test is exactly 0.0
I need to do a chi square test of two of my dataset's categorical variables. This two variables have basically the same meaning but comes from two different sources, so my idea is to use a chi square test to see how similar or correlated, these two variables really are. To do so, I've written code in Python, but the p-value I get from it is exactly 0 which sounds a little strange to me.
the code is:
from scipy.stats import chi2_contingency
import pandas as pd
df = pd.read_csv('data/data_understanding_output.csv')
cont = pd.crosstab(df['sentiment'], df['valence_cat'])
c,p,dof,ex = chi2_contingency(cont)
My contingency table is:
Class 0 | Class 1 | Class 2 | |
---|---|---|---|
Class 0 | 315 | 37 | 2 |
Class 1 | 665 | 2661 | 665 |
Class 2 | 3 | 49 | 285 |
And the trying to output like this my results I get:
print(f{c}\n{p}\n{dof}\n{ex})
1954.0385481800377
0.0
[[ 74.32336608 207.69713798 71.97949594]
[ 837.92246903 2341.57988039 811.49765058]
[ 70.75416489 197.72298163 68.52285348]]
4
So my question is, Did I do anything wrong? Is it normal to have p-value that equals to absolute zero ?
Topic chi-square-test pvalue scipy python
Category Data Science