dask.array.reshape(x, shape, merge_chunks=True)[source]

Reshape array to new shape

shapeint or tuple of ints

The new shape should be compatible with the original shape. If an integer, then the result will be a 1-D array of that length. One shape dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions.

merge_chunksbool, default True

Whether to merge chunks using the logic in dask.array.rechunk() when communication is necessary given the input array chunking and the output shape. With merge_chunks==False, the input array will be rechunked to a chunksize of 1, which can create very many tasks.


This is a parallelized version of the np.reshape function with the following limitations:

  1. It assumes that the array is stored in row-major order

  2. It only allows for reshapings that collapse or merge dimensions like (1, 2, 3, 4) -> (1, 6, 4) or (64,) -> (4, 4, 4)

When communication is necessary this algorithm depends on the logic within rechunk. It endeavors to keep chunk sizes roughly the same when possible.

See Reshaping for a discussion the tradeoffs of merge_chunks.