Array Manipulation Routines#

Basic operations#

copyto(dst, src[, casting, where])

Copies values from one array to another, broadcasting as necessary.

shape(a)

Return the shape of an array.

Changing array shape#

reshape(a, shape)

Gives a new shape to an array without changing its data.

Transpose-like operations#

swapaxes(a, axis1, axis2)

Interchange two axes of an array.

transpose(a[, axes])

Reverse or permute the axes of an array; returns the modified array.

Changing number of dimensions#

atleast_1d(*arys)

Convert inputs to arrays with at least one dimension.

atleast_2d(*arys)

View inputs as arrays with at least two dimensions.

atleast_3d(*arys)

View inputs as arrays with at least three dimensions.

expand_dims(a, axis)

Expand the shape of an array.

squeeze(a[, axis])

Remove single-dimensional entries from the shape of an array.

Changing kind of array#

asarray(a[, dtype, order, like])

Convert the input to an array.

Joining arrays#

concatenate(arrays[, axis, out])

Join a sequence of arrays along an existing axis.

vstack(tup)

Stack arrays in sequence vertically (row wise).

hstack(tup)

Stack arrays in sequence horizontally (column wise).

dstack(tup)

Stack arrays in sequence depth wise (along third axis).

column_stack(tup)

Stack 1-D arrays as columns into a 2-D array.

row_stack(tup)

Stack arrays in sequence vertically (row wise).

Splitting arrays#

split(ary, indices_or_sections[, axis])

Split an array into multiple sub-arrays as views into ary.

Adding and removing elements#

append(*args, **kwargs)

Append values to the end of an array.

Rearranging elements#

reshape(a, shape)

Gives a new shape to an array without changing its data.