We are going to use numpy
In [2]:
import numpy
In [3]:
numpy.loadtxt(fname='data/weather-01.csv', delimiter = ',')
Out[3]:
In [4]:
weight_kg = 55
In [5]:
print weight_kg
In [6]:
print ('Weight in pounds: ', weight_kg * 2.2)
In [7]:
weight_kg = 57.5
In [8]:
print ('New weight: ', weight_kg * 2.2)
In [9]:
%whos
In [10]:
data = numpy.loadtxt(fname='data/weather-01.csv', delimiter = ',')
In [11]:
print data
In [12]:
print type(data)
In [13]:
# finding out the data type
print data.dtype
print data.shape
In [14]:
# Getting a single number out of the array
print 'First value in data: ', data [0,0]
In [15]:
print 'A middle data: ', data [10,10]
In [16]:
# Let's get the first 10 columns for the first 4 rows
print data[0:4,0:10]
In [17]:
print data[:3,36:]
In [18]:
smallchunk = data[3:10,5:12]
doublesmallchunk = smallchunk * 2
In [19]:
print doublesmallchunk
In [20]:
print (numpy.mean(data))
In [21]:
print (numpy.max(data))
In [22]:
print (numpy.min(data))
In [23]:
# get a set of data for the first station
station_0 = data[0,:]
In [24]:
print numpy.max(station_0)
In [25]:
print station_0
In [26]:
# We don't need to create 'temporary' array slices! We can refer to so-called array axes
print numpy.mean(data, axis = 0)
In [27]:
print data
In [28]:
import matplotlib.pyplot
In [29]:
%matplotlib inline
In [30]:
image = matplotlib.pyplot.imshow(data)
In [31]:
# Let's look at the average temperature over time
avg_temperature = numpy.mean(data, axis = 0)
In [32]:
avg_plot = matplotlib.pyplot.plot(avg_temperature)
In [33]:
max_temperature = numpy.max(data, axis = 0)
max_plot = matplotlib.pyplot.plot(max_temperature)
In [34]:
min_temperature = numpy.min(data, axis = 0)
min_plot = matplotlib.pyplot.plot(min_temperature)
In [ ]:
In [ ]:
In [ ]: