Last active
October 29, 2015 22:47
-
-
Save anirudhjayaraman/fc1f8161d97009044834 to your computer and use it in GitHub Desktop.
Manipulating Lists with NumPy
This file contains hidden or 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
import pylab | |
import numpy as np | |
def loadFile(): | |
inFile = open('julyTemps.txt') | |
high = [];vlow = [] | |
for line in inFile: | |
fields = line.split() | |
if len(fields) != 3 or 'Boston' == fields[0] or 'Day' == fields[0]: | |
continue | |
else: | |
high.append(int(fields[1])) | |
low.append(int(fields[2])) | |
return (low, high) | |
def producePlot(lowTemps, highTemps): | |
diffTemps = list(np.array(highTemps) - np.array(lowTemps)) | |
pylab.plot(range(1,32), diffTemps) | |
pylab.title('Day by Day Ranges in Temperature in Boston in July 2012') | |
pylab.xlabel('Days') | |
pylab.ylabel('Temperature Ranges') | |
pylab.show() | |
(low, high) = loadFile() | |
producePlot(low, high) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment