Created
December 12, 2016 19:38
-
-
Save jmsword/3ebb7554c4ad1e4abcad32f967f57170 to your computer and use it in GitHub Desktop.
Chi Squared Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scipy import stats | |
import collections | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
loansData = pd.read_csv('https://github.com/Thinkful-Ed/curric-data-001-data-sets/raw/master/loans/loansData.csv') | |
loansData.dropna(inplace=True) | |
freq = collections.Counter(loansData['Open.CREDIT.Lines']) | |
plt.figure() | |
plt.bar(freq.keys(), freq.values(), width=1) | |
plt.show() | |
chi = stats.chisquare(freq.values()) | |
print("The Chi-Squared value for the 'Open.CREDIT.Lines' column is:", chi, ".") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment