Best practices for numerical computing with NumPy including arrays, broadcasting, and vectorization.
Best practices for numerical computing with NumPy including arrays, broadcasting, and vectorization.
Apply this skill when doing numerical computing with NumPy — arrays, broadcasting, linear algebra, random sampling.
np.float64, np.int32) when creating arrays.np.zeros, np.ones, np.empty, np.arange, np.linspace over list-based construction.np.where() for conditional element-wise operations.np.float32 instead of np.float64 when precision is not critical to halve memory.reshape, slicing) instead of copies when data doesn't need mutation.np.memmap for arrays too large to fit in RAM.np.random.default_rng(seed) (new Generator API) instead of np.random.seed().==; use np.allclose() or np.isclose().np.matrix — it's deprecated; use 2D np.ndarray.