Some examples of using numpy and scipy coming from R. Generally numpy will contain the data structures for vectors and matrices. Scipy will contain the linear algebra and other numerical algorithms. Due to compatability issues some linear algebra functions that would be better under scipy are also contained under numpy.
Basic array operations
Note here that arrays are not vectors in the mathematical sense. All basic math operations will be element-wise for both array-array and array-scalar operations.
Basic matrix operations
Arrays are the “base” object in numpy and more advanced types like matrices are an extension of arrays. Remember that python is object oriented so matrices and arrays are both objects.
For append note that difference between adding a column and adding a row.
Indexing arrays/matrices with conditions
Arrays can be indexed with both sequences of index positions and booleans. This also allows us to subset arrays/matrices using inequalities and other conditions. Same lessons apply to matrices.