← NumPy & Pandas learning path
NumPy & Pandas · Module 1 of 10

NumPy arrays

NumPy gives fast arrays for numerical computing in Python.

📖 Key ideas

  1. import numpy as np.
  2. Create arrays: np.array([1, 2, 3]), np.zeros(5), np.arange(0, 10, 2).
  3. Arrays have shape, dtype and ndim.
  4. NumPy arrays are much faster than Python lists for maths.
  5. All elements share one data type.
💡 Real-life example: A NumPy array is a neatly packed egg tray: same-sized slots, quick to count and process.
ndarrayNumPy's N-dimensional array
shapeSize along each dimension
dtypeData type of elements
np.arangeCreates evenly spaced values