We are going to use a LIBRARY called numpy
In [1]:
    
import numpy
    
In [6]:
    
numpy.loadtxt(fname='data/data/weather-01.csv', delimiter = ',')
    
    Out[6]:
In [3]:
    
!ls
    
    
In [4]:
    
!ls data
    
    
In [5]:
    
!ls data/data
    
    
In [7]:
    
weight_kg = 55
    
In [8]:
    
print (weight_kg)
    
    
In [9]:
    
print('Weight in pounds:', weight_kg*2.2)
    
    
In [10]:
    
weight_kg = 57.5
    
In [11]:
    
print ('New weight:', weight_kg * 2.2)
    
    
In [12]:
    
%whos
    
    
In [13]:
    
data = numpy.loadtxt(fname='data/data/weather-01.csv', delimiter = ',')
    
In [14]:
    
print (data)
    
    
In [15]:
    
print (type(data))
    
    
In [16]:
    
%whos
    
    
In [17]:
    
# Finding out the data type
print(data.dtype)
    
    
In [18]:
    
# Find out the shape
print(data.shape)
    
    
In [19]:
    
# This is 60 rows * 40 columns
    
In [21]:
    
# Getting a single number out of the array
print ("First value in data:",data[0,0])
    
    
In [23]:
    
print ('A middle value:', data[30,20])
    
    
In [24]:
    
# Lets get the first 10 columns for the first 4 rows
print(data[0:4, 0:10])
# Start at index 0 and go up to BUT NOT INCLUDING index 4
    
    
In [25]:
    
# We don't need to start slicing at 0
print (data[5:10, 7:15])
    
    
In [26]:
    
# We don't even need to include the UPPER AND LOWER bounds
smallchunk= data[:3, 36:]
print (smallchunk)
    
    
In [27]:
    
# Arithmetic on array 
doublesmallchunk = small chunk * 2.0
    
    
In [28]:
    
doublesmallchunk = smallchunk * 2.0
    
In [29]:
    
print doublesmallchunk
    
    
In [30]:
    
print(doublesmallchunk)
    
    
In [31]:
    
triplesmallchunk = smallchunk + doublesmallchunk
    
In [32]:
    
print (triplesmallchunk)
    
    
In [33]:
    
print (numpy.mean(data))
    
    
In [34]:
    
print (numpy.max(data))
    
    
In [35]:
    
print (numpy.min(data))
    
    
In [36]:
    
# Get a set of data for the first station
station_0 = data [0, :]
    
In [37]:
    
print (numpy.max(station_0))
    
    
In [38]:
    
# We don't neet to create 'temporary' array slices
# We can refert to what we call array axes
    
In [39]:
    
print (numpy.mean(data, axis = 0)
    
    
In [40]:
    
# axis = 0 gets the mean DOWN each column, so the mean temperatures for each recording time period
print (numpy.mean(data, axis = 0))
    
    
In [41]:
    
# axis = 1 gets the mean ACROSS each row, so the mean temperature for each station across all time periods
print (numpy.mean(data, axis =1))
    
    
In [42]:
    
# Do some simple visualisations
    
In [43]:
    
import matplotlib.pyplot
    
In [44]:
    
%matplotlib inline
    
In [45]:
    
image = matplotlib.pyplot.imshow(data)
    
    
In [46]:
    
# let's take a look at the average temperature over time
avg_temperature = numpy.mean(data, axis 0)
    
    
In [47]:
    
avg_temperature = numpy.mean(data, axis = 0)
    
In [48]:
    
avg_plot= matplotlib.pyplot.plot(avg_temperature)
    
    
Task: produce max and min plots of this data - conclusions
In [49]:
    
max_temperature = numpy.max(data, axis =0)
    
In [50]:
    
print max_temperature
    
    
In [51]:
    
print (max_temperature)
    
    
In [52]:
    
min_temperature = numpy.min(data, axis = 0)
    
In [53]:
    
max_temperature plot= matplotlib.pyplot.plot(max_temperature)
    
    
In [54]:
    
max_plot = matplotlib.pyplot.plot(max_temperature)
    
    
In [55]:
    
min_plot = matplotlib.pyplot.plot(min_temperature)
    
    
In [56]:
    
max_plot = matplotlib.pyplot.plot(max_temperature)
min_plot = matplotlib.pyplot.plot(min_temperature)
avg_plot= matplotlib.pyplot.plot(avg_temperature)
    
    
In [ ]: