NumPy is the Python library for arrays of numbers, and most data tools are built on it, pandas included.
Its core object is the ndarray, short for n-dimensional array.
A Python list stores references to separate objects, each carrying its own type information.
An array stores the raw numbers side by side, so a million 64-bit floats take about 8 megabytes.
Every array has one dtype, such as int64 or float64, that applies to every element.
Mixing types forces a common one, so an array made from 1 and 2.5 becomes an array of floats.
The shape is a tuple of sizes such as (10, 168), and reshaping changes it without copying data where possible.
Indexing works per dimension, so temps[0] is the first city and temps[:, 0] is the first hour for every city.
Slicing usually returns a view of the same memory rather than a copy.
Changing a view changes the original array, which surprises people who expected a copy.
Arrays have a fixed size, so appending a value builds a whole new array.
Growing an array inside a loop is therefore slow; collect the values first and convert once.
Arrays are poor at mixed data such as names next to prices, which is why tables use pandas instead.
Machine learning libraries accept NumPy arrays directly, so data usually reaches a model in this form.
A common slip is comparing two arrays with ==, which returns an array of True and False rather than one answer.