| name | numpy |
| description | High-performance numerical computing with multi-dimensional arrays and mathematical operations. Provides vectorized operations, linear algebra, statistical functions, and matrix manipulation. Use when performing bulk calculations on exchange rates, computing logarithmic transformations, calculating means/standard deviations, doing matrix operations, working with numerical data that needs fast computation, or requiring element-wise operations without loops. Essential for scientific computing and data preprocessing. |
NumPy
Fundamental package for numerical computing in Python.
Quick Start
import numpy as np
# Create arrays
arr = np.array([1, 2, 3])
matrix = np.array([[1, 2], [3, 4]])
zeros = np.zeros((3, 3))
ones = np.ones((2, 4))
Key Functions
# Array operations
np.mean(arr), np.std(arr), np.sum(arr)
np.min(arr), np.max(arr), np.argmax(arr)
# Linear algebra
np.dot(a, b)
np.linalg.inv(matrix)
np.linalg.eig(matrix)
# Reshaping
arr.reshape((2, 3))
arr.flatten()
arr.T # transpose
# Boolean indexing
arr[arr > 0]
np.where(arr > 0, arr, 0)