Python numpy

From wikinotes

Numpy introduces C arrays into python, alongside several fast/compiled functions for operating on those arrays.


Documentation

official intro https://docs.scipy.org/doc/numpy/user/index.html
official docs https://docs.scipy.org/doc/numpy/reference/index.html

Concepts

Arrays

array = numpy.array([
    [0, 1, 2, 3, 4],   # a single 'axis' or 'dimension'
    [5, 6, 7, 8, 9],
    [10, 11, 12, 13, 14],
])

array.ndlm == 3              # number of axes in the array
array.shape == (3, 5)        # (rows, columns)
array.size == 15             # total number of elements, in all axes
array.dtype == numpy.int64   # type of data in the array. (see also numpy.int32, int16, ...)
array.itemsize == 8          # bytes per element (8 bits in byte, so int64 == 64 / 8)