Skip to content

Instantly share code, notes, and snippets.

@anirudhjayaraman
Last active October 29, 2015 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anirudhjayaraman/fc1f8161d97009044834 to your computer and use it in GitHub Desktop.
Save anirudhjayaraman/fc1f8161d97009044834 to your computer and use it in GitHub Desktop.
Manipulating Lists with NumPy
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