NumPy Array Methods Cheat Sheet
1■■ Information / Inspection Methods
Method Description
ndim Number of dimensions
shape Rows × Columns
size Total number of elements
dtype Data type (int, float, etc.)
itemsize Size of one element (bytes)
nbytes Total bytes consumed
T Transpose (shortcut for .transpose())
2■■ Reshaping / Changing Structure
Method Description
reshape() Change shape
flatten() Convert to 1D
ravel() Flatten (view, not copy)
transpose() Flip rows and cols
resize() Change size in-place
swapaxes() Swap two axes
squeeze() Remove single-dimensional entries
expand_dims() Add a new axis
3■■ Mathematical / Statistical Methods
Method Description
sum() Sum of all elements
mean() Mean of elements
std() Standard deviation
var() Variance
min() / max() Minimum / Maximum
argmin() / argmax() Indices of min / max
prod() Product of all elements
cumsum() / cumprod() Cumulative sum / product
4■■ Logical / Comparison Methods
Method Description
all() True if all elements are True
any() True if any element is True
nonzero() Indices of non-zero elements
where() Conditional selection
clip() Limit values to a range
5■■ Copying / Conversion
Method Description
copy() Create a deep copy
tolist() Convert to Python list
astype() Convert data type
view() Create a view of array
6■■ Sorting / Searching
Method Description
sort() Sort elements
argsort() Indices that would sort array
searchsorted() Find insert positions
unique() Find unique elements
7■■ Linear Algebra ([Link])
Method Description
dot() or @ Matrix multiplication
det() Determinant
inv() Inverse
eig() Eigenvalues and vectors
norm() Norm (length)
solve() Solve linear equations