Numpy

Excellent summary.

import numpy as np

Broadcasting

a = np.zeros([3,4])
a
array([[0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [0., 0., 0., 0.]])
rows = np.array([0,2])
vec = np.array([1,2,3]).reshape(1,-1).T
a[:,rows] += vec
a
array([[1., 0., 1., 0.],
       [2., 0., 2., 0.],
       [3., 0., 3., 0.]])

Indexing

a = np.arange(1, 10).reshape(3, 3)
a
array([[1, 2, 3],
       [4, 5, 6],
       [7, 8, 9]])
# An example of integer array indexing.
# The returned array will have shape (3,)
a[[0, 1, 2], [0, 1, 0]]
array([1, 5, 7])
b = a[range(3), [0,2,1]]
b
array([1, 6, 8])

Row to Column

b[:, np.newaxis]
array([[1],
       [6],
       [8]])
b[..., None]
array([[1],
       [6],
       [8]])