ofile = open('mosquito_data_A1.csv', 'r') print ofile.read() import numpy as np np.genfromtxt('mosquito_data_A1.csv', unpack = True, skiprows = 1, delimiter = ',') d = np.genfromtxt('mosquito_data_A1.csv', skiprows = 1, delimiter = ',', unpack = True) print d data = np.genfromtxt('mosquito_data_A1.csv', skiprows = 1, delimiter = ',', unpack = True) a, b, c = [1, 2, 3] print a print b year, temperature, rainfall, mosquitos = data print year print type(temperature) print temperature * 4 print temperature + temperature my_list = [1, 2, 3, 'a', 'c'] print type(my_list) print my_list * 4 print my_list + [4] print my_list + 4 print year print year[0] print year[2:5] print year[:3] print year[2:] print year[-3:] x = 2 dir(x) print x.bit_length() print temperature.mean() print data. print year.min() print mosquitos[1:3].std() year, temperature, rainfall, mosquitos = np.genfromtxt('mosquito_data_A1.csv', skiprows = 1, delimiter = ',', unpack = True) print temperature.mean() print temperature.std() print rainfall.mean() print rainfall.std() for temp_in_f in temperature: temp_in_c = (temp_in_f - 32) * 5 / 9.0 print temp_in_c print '10/3 is:', 10 / 3 print '10/3.0 is:', 10 / 3.0 if temperature[0] > 80: print "The temperature is greater than 80" if temperature[0] < 87: print "The temperature is < 87" elif temperature[0] > 87: print "The temperature is > 87" else: print " The temperature is equal to 87" year, temperature, rainfall, mosquitos = np.genfromtxt('mosquito_data_A1.csv', skiprows = 1, delimiter = ',', unpack = True) for temp in temperature: if temp > temperature.mean(): print 'temp is greater than mean' elif temp < temperature.mean(): print 'temp is less than mean' else: print 'temp is equal to mean' year, temperature, rainfall, mosquitos = np.genfromtxt('mosquito_data_A1.csv', skiprows = 1, delimiter = ',', unpack = True) from matplotlib import pyplot pyplot.plot(temperature, mosquitos) pyplot.cla() pyplot.plot(temperature, mosquitos, 'o') fit_coeff = np.polyfit(temperature, mosquitos, 1) print fit_coeff fit_to_data = fit_coeff[0] * temperature + fit_coeff[1] pyplot.plot(temperature, fit_to_data) def read_csv_file(): ''' This code will read in a CSV file of year, temperature, rainfall, and number of mosquitos and return 4 arrays, one for each column ''' pass def convert_fahrenheit_to_celsius(): ''' This code will convert an array of tempertures from fahrenheit to celsius ''' pass def plot_data(): ''' This code will plot the arrays in x and y with symbol (default "o") ''' pass help(plot_data) help(np.polyfit) read_csv_file() convert_fahrenheit_to_celsius() plot_data() def read_csv_file(filename): ''' This code will read in a CSV file of year, temperature, rainfall, and number of mosquitos and return 4 arrays, one for each column ''' year, temperature, rainfall, mosquitos = np.genfromtxt(filename, skiprows = 1, delimiter = ',', unpack = True) return year, temperature, rainfall, mosquitos def convert_fahrenheit_to_celsius(): ''' This code will convert an array of tempertures from fahrenheit to celsius ''' pass def plot_data(): ''' This code will plot the arrays in x and y with symbol (default "o") ''' pass read_csv_file('mosquito_data_A1.csv') year, temperature, rainfall, mosquitos = read_csv_file('mosquito_data_A1.csv') print year def read_csv_file(filename): ''' This code will read in a CSV file of year, temperature, rainfall, and number of mosquitos and return 4 arrays, one for each column ''' year, temperature, rainfall, mosquitos = np.genfromtxt(filename, skiprows = 1, delimiter = ',', unpack = True) return year, temperature, rainfall, mosquitos def convert_fahrenheit_to_celsius(temp_in_f): ''' This code will convert an array of tempertures from fahrenheit to celsius ''' temp_in_c = (temp_in_f - 32) * 5 / 9.0 return temp_in_c def plot_data(): ''' This code will plot the arrays in x and y with symbol (default "o") ''' pass year, temperature, rainfall, mosquitos = read_csv_file('mosquito_data_A1.csv') temp_in_c = convert_fahrenheit_to_celsius(temperature) print temperature, temp_in_c def plot_data(x, y, symbol = 'o'): ''' This code will plot the arrays in x and y with symbol (default "o") ''' pyplot.plot(x, y, symbol) pyplot.savefig('temp_vs_mosquitos.pdf') pyplot.close() def plot_data(x, y, symbol = 'o'): ''' This code will plot the arrays in x and y with symbol (default "o") ''' pyplot.plot(x, y, symbol) pyplot.savefig('temp_vs_mosquitos.pdf') pyplot.close() year, temperature, rainfall, mosquitos = read_csv_file('mosquito_data_A1.csv') temp_in_c = convert_fahrenheit_to_celsius(temperature) plot_data()