I could never grasp the conventions for "axis=". Everyone has some memory trick, some of them being confusing/wrong.
On the other hand einsum is Crystal clear and not prone to confusion.
> np.einsum("ij -> j", B) # sum along rows to create one column-like array
> np.einsum("ij -> i", B) # sum along columns to create one row-like array
Edit: More Einstein sum fun at https://stackoverflow.com/questions/26089893/understanding-n...