In [2]:
import numpy
import matplotlib.pyplot
%matplotlib inline
In [3]:
data = numpy.loadtxt (fname ='data/weather-01.csv', delimiter = ',')
In [16]:
# Create a wide figure to hold the subplots
fig = matplotlib.pyplot.figure (figsize=(10.0, 3.0))
# Create diferrent boxis with in the main frame "place holders for plots"
subplot1 = fig.add_subplot (1,3,1)
subplot2 = fig.add_subplot (1,3,2)
subplot3 = fig.add_subplot (1,3,3)
subplot1.set_ylabel ('average temperature')
subplot1.plot (numpy.mean (data, axis=0))
subplot2.set_ylabel ('minimum')
subplot2.plot (numpy.min (data, axis=0))
subplot3.set_ylabel ('maximum')
subplot3.plot (numpy.max (data, axis=0))
#subplot1.set_xlabel ('Station')
#subplot1.plot (numpy.mean (data, axis=1))
fig.tight_layout()
matplotlib.pyplot.show()
In [17]:
word = "notebook"
print (word[4])
In [18]:
for char in word:
print (char)
In [19]:
import glob
In [20]:
print (glob.glob ('data/weather*.csv'))
In [32]:
filenames = sorted(glob.glob ('data/weather*.csv'))
filenames = filenames[0:3]
for f in filenames:
print (f)
data = numpy.loadtxt (fname=f, delimiter=',')
if numpy.max (data, axis = 0)[0] == 0 and numpy.max (data, axis=0)[20] == 20:
print ("Suspicios looking data maxima")
elif numpy.sum (numpy.min(data, axis=0)) == 0:
print ("Minima add up to zero")
else:
print ("Data looks OK")
# Create a wide figure to hold the subplots
fig = matplotlib.pyplot.figure (figsize=(10.0, 3.0))
# Create diferrent boxis with in the main frame "place holders for plots"
subplot1 = fig.add_subplot (1,3,1)
subplot2 = fig.add_subplot (1,3,2)
subplot3 = fig.add_subplot (1,3,3)
subplot1.set_ylabel ('average temperature')
subplot1.plot (numpy.mean (data, axis=0))
subplot2.set_ylabel ('minimum')
subplot2.plot (numpy.min (data, axis=0))
subplot3.set_ylabel ('maximum')
subplot3.plot (numpy.max (data, axis=0))
#subplot1.set_xlabel ('Station')
#subplot1.plot (numpy.mean (data, axis=1))
fig.tight_layout()
matplotlib.pyplot.show()
In [24]:
num = 107
if num > 100:
print ('Greater')
else:
print ('Not greater')
print ('Done')
In [25]:
## Ojo el Done antes y despues
num = 107
if num > 100:
print ('Greater')
else:
print ('Not greater')
print ('Done')
In [28]:
num = -3
if num > 0:
print (num, "is positive")
elif num == 0:
print (num, "is zero")
else:
print (num, "is negative")
In [33]:
def fahr_to_kelvin(temp):
return ((temp - 32)*(5/9) + 273.15)
In [35]:
fahr_to_kelvin (20)
Out[35]:
In [36]:
print ("Freezing point of water:", fahr_to_kelvin(32))
In [37]:
print ('Boiling point of water:', fahr_to_kelvin(212))
In [38]:
def analyse (filename):
data = numpy.loadtxt (fname=filename, delimiter=',')
# Create a wide figure to hold the subplots
fig = matplotlib.pyplot.figure (figsize=(10.0, 3.0))
# Create diferrent boxis with in the main frame "place holders for plots"
subplot1 = fig.add_subplot (1,3,1)
subplot2 = fig.add_subplot (1,3,2)
subplot3 = fig.add_subplot (1,3,3)
subplot1.set_ylabel ('average temperature')
subplot1.plot (numpy.mean (data, axis=0))
subplot2.set_ylabel ('minimum')
subplot2.plot (numpy.min (data, axis=0))
subplot3.set_ylabel ('maximum')
subplot3.plot (numpy.max (data, axis=0))
#subplot1.set_xlabel ('Station')
#subplot1.plot (numpy.mean (data, axis=1))
fig.tight_layout()
matplotlib.pyplot.show()
In [39]:
def detect_problems (filename):
data = numpy.loadtxt (fname=filename, delimiter=',')
if numpy.max (data, axis = 0)[0] == 0 and numpy.max (data, axis=0)[20] == 20:
print ("Suspicios looking data maxima")
elif numpy.sum (numpy.min(data, axis=0)) == 0:
print ("Minima add up to zero")
else:
print ("Data looks OK")
In [41]:
for f in filenames [0:5]:
print (f)
analyse (f)
detect_problems (f)
In [ ]: