```
In [27]: x = np.arange(16).reshape((4,2,2))
In [28]: x.reshape(2,2,2,2).swapaxes(1,2).reshape(4,-1)
Out[28]:
array([[ 0, 1, 4, 5],
[ 2, 3, 6, 7],
[ 8, 9, 12, 13],
[10, 11, 14, 15]])
```

I’ve posted more general functions for reshaping/unshaping arrays into blocks, here.

### Related Contents:

- Check if two 3D numpy arrays contain overlapping 2D arrays
- What is the difference between ndarray and array in NumPy?
- What are the advantages of NumPy over regular Python lists?
- Using numpy to build an array of all combinations of two arrays
- Understanding NumPy’s einsum
- Intuition and idea behind reshaping 4D array to 2D array in NumPy
- How does numpy.newaxis work and when to use it?
- What is the difference between flatten and ravel functions in numpy?
- Concatenating two one-dimensional NumPy arrays
- Why is numpy’s einsum faster than numpy’s built in functions?
- Calculate mean across dimension in a 2D array
- Convert a 1D array to a 2D array in numpy
- What is the purpose of meshgrid in Python / NumPy?
- How do I use np.newaxis?
- Selecting specific rows and columns from NumPy array
- Subsetting a 2D numpy array
- Selecting Random Windows from Multidimensional Numpy Array Rows
- How to split a numpy array in fixed size chunks with and without overlap?
- Mapping a NumPy array in place
- How to find the index of a value in 2d array in Python?
- Partition array into N chunks with Numpy
- Convert pandas dataframe to NumPy array
- Difference between numpy.array shape (R, 1) and (R,)
- How to convert a PIL Image into a numpy array?
- Performance of Pandas apply vs np.vectorize to create new column from existing columns
- Removing nan values from an array
- How to remove specific elements in a numpy array
- How do I count the occurrence of a certain item in an ndarray?
- Numpy sum elements in array based on its value
- Count consecutive occurences of values varying in length in a numpy array
- How to normalize a NumPy array to within a certain range?
- Get the position of the largest value in a multi-dimensional NumPy array
- Getting the indices of several elements in a NumPy array at once
- How do I create an empty array and then append to it in NumPy?
- How to do n-D distance and nearest neighbor calculations on numpy arrays
- How do I print the full NumPy array, without truncation?
- How do I convert a PIL Image into a NumPy array?
- How do I calculate percentiles with python/numpy?
- Why does numpy.zeros takes up little space
- Python: slicing a multi-dimensional array
- Using Numpy Vectorize on Functions that Return Vectors
- NumPy chained comparison with two predicates
- Find elements of array one nearest to elements of array two
- Interweaving two NumPy arrays efficiently
- 2D array indexing
- Parameters to numpy’s fromfunction
- Sort invariant for numpy.argsort with multiple dimensions
- remove zero lines 2-D numpy array
- Why is Numpy much faster at creating a Zero array compared to replacing the values of an existing array with zeros?
- What’s the simplest way to extend a numpy array in 2 dimensions?