List of NumPy articles
Contents
- Versions and settings
- Basics of
ndarray
- File inputs and outputs
- Converting
ndarray
to other types - Creating
ndarray
- Reshaping
ndarray
- Extracting, adding, deleting elements, rows, and columns
- Concatenating and splitting
ndarray
- Operations by conditions
- Handling missing values (
np.nan
) - Mathematical operations
- Matrix operations
- Image processing
- Other operations
- Other tips
Versions and settings
- Check NumPy version: np.version
- Set the display format for ndarray
- Set whether to print full or truncated ndarray
Basics of ndarray
- Difference between lists, arrays and numpy.ndarray in Python
- Cast ndarray to a specific dtype with astype()
- Broadcasting rules and examples
- Meaning of the axis parameter (0, 1, -1)
- Compare ndarray element by element
- Determine if ndarray is view or copy and if it shares memory
- Make arrays immutable (read-only) with the WRITEABLE attribute
File inputs and outputs
- Read and write CSV files (np.loadtxt, np.genfromtxt, np.savetxt)
- Save and load arrays in npy and npz files
Converting ndarray
to other types
Creating ndarray
- Create an array with the same value (np.zeros, np.ones, np.full)
- Create an empty array (np.empty, np.empty_like)
- Generate random numbers with np.random
- Generate evenly spaced values with np.arange and np.linspace
Reshaping ndarray
- Get the number of dimensions, shape, and size of ndarray
- How to use reshape() and the meaning of -1
- Flatten ndarray (ravel(), flatten())
- Add new dimensions to ndarray (np.newaxis, np.expand_dims)
- Transpose ndarray (swap rows and columns, rearrange axes)
- Remove dimensions of size 1 from ndarray (np.squeeze)
Extracting, adding, deleting elements, rows, and columns
- Get and set values in an array using various indexing
- Slicing ndarray
- Ellipsis (...) for ndarray
- Add elements, rows, and columns to an array with np.append()
- Insert elements, rows, and columns into an array with np.insert()
- Delete rows and columns of ndarray with np.delete()
Concatenating and splitting ndarray
- Concatenate arrays with np.concatenate, np.stack, etc.
- Arrange ndarray in tiles with np.tile()
- Split an array with np.split, np.vsplit, np.hsplit, etc.
Operations by conditions
- numpy.where(): Manipulate elements depending on conditions
- Extract or delete elements, rows, and columns that satisfy the conditions
- Count the number of elements satisfying the condition
Handling missing values (np.nan
)
- Replace NaN (np.nan) in ndarray
- Remove rows/columns with missing value (NaN) in ndarray
- Calculate the sum, mean, max, min of ndarray containing np.nan
Mathematical operations
- Sum, mean, max, min for entire array, column/row-wise
- Limit ndarray values to min and max with clip()
- Calculate the absolute value element-wise (np.abs, np.fabs)
- Round array elements (np.round, np.around, np.rint)
- Round up/down the elements of a ndarray (np.floor, trunc, ceil)
- Trigonometric functions (sin, cos, tan, arcsin, arccos, arctan)
- Calculate cumulative sum and product (np.cumsum, np.cumprod)
- np.sign(), np.signbit(), np.copysign()
Matrix operations
Image processing
- Image processing with Python, NumPy
- Get image size (width, height) with Python, OpenCV, Pillow (PIL)
- Binarize image with Python, NumPy, OpenCV
- Alpha blending and masking of images with Python, OpenCV, NumPy
- Generate gradient image with Python, NumPy