Matrices
A DataFrame is generally composed of rows, and each row has the same number of columns. From one point of view, it's a two-dimensional grid containing lots of numbers. It can also be interpreted as a list of lists, or an array of arrays.
In mathematics, a matrix is a rectangular array of numbers defined by the number of rows and columns. It is standard always to list rows first, and columns second. For instance, a 2 x 3 matrix consists of 2 rows and 3 columns, whereas a 3 x 2 matrix consists of 3 rows and 2 columns.
Here is a 4 x 4 matrix:
Exercise 132: Matrices
NumPy has methods for creating matrices or n-dimensional arrays. One option is to place random numbers between 0 and 1 into each entry, as follows.
In this exercise, you will implement the various numpy
matrix methods and observe the outputs (recall that random.seed
will allow us to reproduce the same numbers, and it&apos...