# initiate a few variables i = 0 ID = [] GDP = [] FertRate = [] # read csv file and store data in arrays x and y import csv with open('Lesson15_GDPFertAmer.csv', 'rb') as csvfile: reader = csv.reader(csvfile) for row in reader: i += 1 #print i Amer = row ID.append(int(Amer[0])) GDP.append(float(Amer[1])) FertRate.append(float(Amer[2])) #print x #print y print ("ID") print ID print ("GDP") print GDP print ("Fertility Rate") print FertRate # now use arrays x and y to run linear regression import scipy.stats as stats lr = stats.linregress slope, intercept, rvalue, pvalue, stderr = lr(GDP,FertRate) # print results to screen print ("slope, intercept, r-sqr, n") print slope print intercept print rvalue**2 print i print ("Boom!")