In [14]:
import numpy
In [15]:
numpy.loadtxt(fname='data/weather-01.csv', delimiter = ',')
Out[15]:
In [5]:
weight_kg = 55
In [10]:
print (weight_kg)
In [6]:
print ('Weight in pounds:', weight_kg * 2.2)
In [7]:
weight_kg = 57.5
In [8]:
print ('Weight in pounds:', weight_kg * 2.2)
In [16]:
%whos
In [6]:
data = numpy.loadtxt(fname='data/weather-01.csv', delimiter = ',')
In [13]:
print (data)
In [14]:
print (type(data))
In [15]:
%whos
In [16]:
# Finding out the data type
print (data.dtype)
In [17]:
# Find out the shape
print (data.shape)
In [18]:
# 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]:
# Lets get the first 10 columns for the first 4 rows
print (data [0:4, 0:10])
# start at index 0 and go upt to But not including index 4
In [22]:
# We don`t neet to start slicing at 0
print (data[5:10, 7:15])
In [17]:
# We dont even need to include the UPPER and LOWER bounds
smallchunk = data [:3, 36:]
print (smallchunk)
In [18]:
# Arithmetic on arrays
doublesmallchunk = smallchunk * 2.0
In [25]:
print (doublesmallchunk)
In [19]:
triplesmallchunk = smallchunk + doublesmallchunk
In [27]:
print (triplesmallchunk)
In [28]:
print (numpy.mean (data))
In [29]:
print (numpy.max(data))
In [30]:
print (numpy.min(data))
In [20]:
# Get a set of data for the first station
station_0 = data [0, :]
In [32]:
print (numpy.max (station_0))
In [33]:
# 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 temperatura for each recording period
print (numpy.mean (data, axis = 0))
In [8]:
# Axis = 1 gets the mean Across each row, so the mean temperatura for each recording period
print (numpy.mean (data, axis = 1))
In [37]:
# Do some simple visualisations
In [21]:
import matplotlib.pyplot
In [22]:
%matplotlib inline
In [23]:
image = matplotlib.pyplot.imshow(data)
In [24]:
# Let's look at the average temperature over time
avg_temperature = numpy.mean (data, axis = 0)
In [25]:
avg_plot = matplotlib.pyplot.plot(avg_temperature)
Task:
- Produce maximum and minimum plots of this data
- What do you think?
In [27]:
Max_plot = matplotlib.pyplot.plot (numpy.max(data, axis =0))
In [29]:
Min_plot = matplotlib.pyplot.plot (numpy.min(data, axis =0))
In [30]:
max_temp = numpy.max (data, axis=0)
min_temp = numpy.min (data, axis=0)
In [31]:
max_plot = matplotlib.pyplot.plot (max_temp)
min_plot = matplotlib.pyplot.plot (min_temp)
In [ ]: