PYTHON APPLIEDChapter 13 · Python for Data Science
NumPy arrays and vectorized math
NumPy is the foundation of scientific Python. Its ndarray stores homogeneous data in contiguous memory, enabling vectorized operations that run orders of magnitude faster than Python loops.
Worked example
How it reads
- np.array([...]) creates a NumPy array from a Python list
- **temps * 9 / 5 + 32** applies math to every element at once (vectorized)
- .mean(), .max(), .std() compute statistics without loops

Cloud tip: NumPy arrays must contain elements of the same type (all ints or all floats). This constraint enables the speed gains.


