Let's now talk about NumPy arrays, which are called ndarray
. These are not the arrays you may encounter in C or C++. A better analog is matrices in MATLAB or R; that is, they behave like a mathematical object resembling a mathematical vector, matrix, or tensor. While they can store non-mathematical information such as strings, they exist mainly to manage and facilitate operations with data that is numeric in nature. ndarray
are assigned a particular data type or dtype
upon creation, and all current and future data in the array must be of that dtype
. They also have more than one-dimension, referred to as axes.
A one-dimensional ndarray
is a line of data; this would be a vector. A two-dimensional ndarray
would be a square of data, effectively a matrix. A three-dimensional ndarray
would be key book data, like a tensor. Any number of dimensions is permitted, but most ndarray
are one or two-dimensional.
dtype
are similar to types in the basic Python language, but NumPy dtype
resemble...