Important Notice:

NumPy Basics

NumPy Basics

16 views 1 min read

NumPy

NumPy (Numerical Python) provides arrays and math functions.

Install & Importpip install numpy\nimport numpy as npCreating Arraysa = np.array([1, 2, 3, 4, 5])\nprint(a.shape) # (5,)\nprint(a.dtype) # int64\n\nb = np.array([[1,2,3],[4,5,6]])\nprint(b.shape) # (2, 3)NumPy FunctionsFunctionDescriptionnp.zeros(n)Array of zerosnp.ones(n)Array of onesnp.arange(start,stop,step)Range arraynp.sum()Sumnp.mean()Averagenp.max()/np.min()Max/MinArray Operationsa = np.array([1,2,3])\nprint(a + 10) # [11 12 13]\nprint(a * 2) # [2 4 6]\nprint(a ** 2) # [1 4 9]