We are going to use a LIBRARY called nampy
In [5]:
    
import numpy
    
In [6]:
    
numpy.loadtxt(fname='data/weather-01.csv', delimiter = ',')
    
    Out[6]:
In [7]:
    
weight_kg=55
    
In [8]:
    
print [weight_kg]
    
    
In [9]:
    
print (weight_kg)
    
    
In [10]:
    
print ('weight in pounds: ', weight_kg * 2.2 )
    
    
In [11]:
    
weight_kg=57.5
    
In [12]:
    
print ('New weight: ', weight_kg * 2.2)
    
    
In [13]:
    
%whos
    
    
In [14]:
    
data=numpy.loadtxt(fname='data/weather-01.csv', delimiter = ',')
    
In [15]:
    
print (data)
    
    
In [16]:
    
print(type(data))
    
    
In [17]:
    
#Find out the data type
print (data.dtype)
    
    
In [18]:
    
#find out the shape
print (data.shape)
    
    
In [15]:
    
#This is 60 rows * 40 columns
    
In [19]:
    
#Getting a single number out of the array
print ("First value in data: ", data [0, 0])
    
    
In [20]:
    
print ('A middle value: ', data[30, 20])
    
    
In [21]:
    
# Letsget the 1st 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 [22]:
    
#We don't need to start slicingf at 0
print (data[5:10, 7:15])
    
    
In [23]:
    
#We don't even need to include the UPPER or LOWER bounds
smallchunck = data [:3, 36:]
print (smallchunck)
    
    
In [24]:
    
#Arithmetic on arrays
doublesmallchunck = smallchunck * 2.0
    
In [25]:
    
print (doublesmallchunck)
    
    
In [26]:
    
triplesmallchunck = smallchunck + doublesmallchunck
    
In [27]:
    
print(triplesmallchunck)
    
    
In [28]:
    
print (numpy.mean(data))
    
    
In [29]:
    
print (numpy.max(data))
    
    
In [30]:
    
print (numpy.min(data))
    
    
In [31]:
    
#Get a set of data for the first station 0 means everyting from the first row and : means all the columns
station_0 = data [0, :]
    
In [32]:
    
print (station_0)
    
    
In [33]:
    
print (numpy.max(station_0))
    
    
In [34]:
    
#We don't need to create 'temporary' array slices
#We can refer to what we call array axes
    
In [35]:
    
# axis = 0 gets the mean down each column, so the mean temperature for each recording period
print (numpy.mean(data, axis = 0))
    
    
In [36]:
    
# axis = 1 gets the mean ACROSS each row, so the mean temperature for each station for all the periods
print (numpy.mean(data, axis = 1))
    
    
In [37]:
    
# Do some simple visualisations
    
In [38]:
    
import matplotlib.pyplot
    
In [39]:
    
%matplotlib inline
    
In [40]:
    
image = matplotlib.pyplot.imshow(data)
    
    
In [38]:
    
#Let's look at the average temperature over time
avg_temperature = numpy.means(data, axis = 0)
    
    
In [41]:
    
#Let's look at the average temperature over time
avg_temperature = numpy.mean(data, axis = 0)
    
In [42]:
    
avg_plot = matplotlib.pyplot.plot(avg.temperature)
    
    
In [43]:
    
avg_plot = matplotlib.pyplot.plot(avg_temperature)
    
    
In [44]:
    
max_temperature = numpy.max (data, axis=0)
    
In [45]:
    
max_temperature = numpy.max (data, axis=0)
min_temperature = numpy.min (data, axis=0)
    
In [46]:
    
max_plot = matplotlib.pyplot.plot(max_temperature)
min_plot = matplotlib.pyplot.plot(min_temperature)
    
    
In [ ]: