Posts

NumPy - Broadcasting

Broadcasting in NumPy allows universal functions to operate on arrays with different shapes by implicitly expanding them to compatible shapes. There are two main rules of broadcasting: Prepending Dimensions : If two arrays have different numbers of dimensions, the array with fewer dimensions will have ones prepended to its shape until both shapes have the same length. Size Matching : After the dimensions are aligned, if any dimension of either array has size 1, it is stretched to match the size of the corresponding dimension in the other array. If neither array has size 1 along a dimension, the operation fails. These rules enable NumPy to perform element-wise operations even when the shapes of the input arrays are not identical, as long as they are compatible according to the broadcasting rules. This functionality greatly enhances the flexibility and ease of use of NumPy for array operations. More detailed information about broadcasting can be found in the NumPy documentation.

Num py - Functions and Methods

  Functions and methods overview Here is a list of some useful NumPy functions and methods names ordered in categories. See  Routines and objects by topic  for the full list. Array Creation arange ,  array ,  copy ,  empty ,  empty_like ,  eye ,  fromfile ,  fromfunction ,  identity ,  linspace ,  logspace ,  mgrid ,  ogrid ,  ones ,  ones_like ,  r_ ,  zeros ,  zeros_like Conversions ndarray.astype ,  atleast_1d ,  atleast_2d ,  atleast_3d ,  mat Manipulations array_split ,  column_stack ,  concatenate ,  diagonal ,  dsplit ,  dstack ,  hsplit ,  hstack ,  ndarray.item ,  newaxis ,  ravel ,  repeat ,  reshape ,  resize ,  squeeze ,  swapaxes ,  take ,  transpose ,  vsplit ,  vstack Questions all ,  any ,  nonzero ,  where Ordering argmax ,  argmin , ...