Python NumPy Library
NumPy (Numerical Python) is a foundational open-source Python library for numerical and mathematical computation. It introduces the N-dimensional array ( ndarray ), a high-performance data structure for storing and manipulating large datasets efficiently. NumPy forms the computational foundation of the Python data-science ecosystem; major libraries such as Pandas, SciPy, scikit-learn, and TensorFlow build directly upon it. This tutorial is designed to provide a concise yet practical overview of NumPy and to support day-to-day technical work through clear, task-oriented examples. Key characteristics High performance: NumPy operations are implemented in highly optimised C, enabling many numerical workloads to run substantially faster than equivalent operations on standard Python lists. Vectorisation: NumPy reduces reliance on explicit Python loops by applying operations across entire arrays in a single expression. Memory efficiency: NumPy arrays store homogeneous data in contiguous memory blocks, typically reducing memory overhead relative to Python lists. Core features and capabilities NumPy provides a broad suite of tools for numerical computation, including: Multidimensional arrays: Creation and manipulation of 1D vectors, 2D matrices, and higher-dimensional structures. Broadcasting: Arithmetic operations between arrays of different, but compatible, shapes. Linear algebra: Built-in routines for matrix multiplication, determinants, inverses, and systems of linear equations. Random number generation: Utilities for generating random samples from common statistical distributions. Mathematical functions: Fast element-wise operations for trigonometric, logarithmic, exponential, and statistical calculations (for example, mean, median, and standard deviation). Python lists vs NumPy ndarrays Python lists can store heterogeneous data types (for example, strings, integers, and objects) in a single container. This flexibility is useful, but lists are comparatively inefficient