NumPy / SciPy
Prof. Dr. Nicolas Rohleder, Prof. Dr. Björn Eskofier, Veronika Ringgold, Luca Abel, Robert Richer · 10 concepts · 10 questions
Concept 1 / 10
Why NumPy? The ndarray
NumPy is the foundation of numerical computing in Python. Its central object is the ndarray (n-dimensional array): a container holding elements of a single fixed type in a contiguous block of memory.
For a collection of numbers of the same type, an ndarray is far more efficient than a generic Python list, both in memory and — crucially — in speed. Operations on arrays run in optimised, compiled code rather than in slow interpreted Python loops.
The conventional import alias is np:
import numpy as nppandas is built directly on top of NumPy, so the concepts here (the axis argument, boolean masks, reductions) carry straight over to DataFrames.