Relative Content

Tag Archive for pythonnumpynumpy-ndarray

Flattening groups of indices in a numpy array

Suppose I have a four-dimensional array and I would like to flatten the first two indices and the last two indices. For example, with a 2x2x2x2 array, this would yield a (2×2)x(2×2)=4×4 array. How can I do this?

Storing numpy array in raw binary file

How to store a 2D numpy ndarray in raw binary format? It should become a raw array of float32 values, in row-major order, no padding, without any headers.