Skip to content
Back to course

10.5 NumPy

NumPy is the foundational Python library for numerical computing. Its core object is the ndarray — a fast, memory-efficient multi-dimensional array — which lets you do math on whole collections of numbers at once instead of looping element by element.

Because the heavy math runs in optimized lower-level code, NumPy is far faster than plain Python lists for large datasets. If you wanted to convert a list of 10,000 temperatures from Celsius to Fahrenheit, NumPy does it in one quick operation across the whole array.

Scenario

You must multiply every number in a million-element dataset by 2, as fast as possible in Python. What is the best approach?

Check your understanding

1/4 · 40 XP

What is the core data object in NumPy?