Summary
This chapter informed us about a great number of common NumPy functions. We read a file with loadtxt
and wrote to a file with savetxt
. We made an identity matrix with the eye
function. We read a CSV file containing stock quotes with the loadtxt
function. The NumPy average
and mean
functions allow one to calculate the weighted average and arithmetic mean of a data set.
A few common statistics functions were also mentioned – first, the min
and max
functions that we used to determine the range of the stock prices; second, the median
function that gives the median of a data set; and finally, the std
and var
functions that return the standard deviation and variance of a set of numbers.
We calculated the simple stock returns with the diff
function that returns back the differences between sequential elements. The log
function computes the natural logarithms of array elements.
By default, loadtxt
tries to convert all data into floats. The loadtxt
function has a special parameter for this purpose...