What is NumPy
NumPy is a toolbox that lets Python handle big tables of numbers quickly, the way a spreadsheet does, but from code.
In this page:
What is NumPy
NumPy (Numerical Python) is the foundational library for numerical computing in Python. It provides the ndarray, a fast multi-dimensional array, plus hundreds of functions that operate on whole arrays at once.
Libraries such as Pandas, SciPy, scikit-learn and Matplotlib are all built on top of it.
Note:
NumPy's core is written in C, which is why array operations run at near-C speed while you write friendly Python.
Example: What is NumPy
import numpy as np
a = np.array([10, 20, 30, 40])
print("Array:", a)
print("Type:", type(a))
print("Doubled:", a * 2)
# Output:
# Array: [10 20 30 40]
# Type: <class 'numpy.ndarray'>
# Doubled: [20 40 60 80]
Related Topics
Common Mistakes
- Thinking NumPy is a separate language instead of a Python library
- Forgetting that NumPy arrays hold one data type, unlike Python lists
- Looping over arrays element by element instead of using vectorized operations
Chapter Summary
- NumPy is Python's core library for numerical computing
- Its central object is the ndarray
- It operates on whole arrays at once (vectorization)
- Pandas, SciPy and scikit-learn build on it
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: