Array manipulation routines¶
Changing array shape¶
reshape(a, newshape[, order, out]) |
Gives a new shape to an array without changing its data. |
ravel(x) |
Return a contiguous flattened array. |
ndarray.flatten(self[, order]) |
Return a copy of the array collapsed into one dimension. |
ndarray.flat
Transpose-like operations¶
swapaxes(a, axis1, axis2) |
Interchange two axes of an array. |
ndarray.T |
Same as self.transpose(). |
transpose(a[, axes]) |
Permute the dimensions of an array. |
moveaxis(a, source, destination) |
Move axes of an array to new positions. |
rollaxis
Changing number of dimensions¶
expand_dims(a, axis) |
Expand the shape of an array. |
squeeze(a[, axis, out]) |
Remove single-dimensional entries from the shape of an array. |
broadcast_to(array, shape[, out]) |
Broadcast an array to a new shape. |
broadcast_arrays(\*args) |
Broadcast any number of arrays against each other. |
atleast_1d
atleast_2d
atleast_3d
broadcast
Changing kind of array¶
asarray
asanyarray
asmatrix
asfarray
asfortranarray
ascontiguousarray
asarray_chkfinite
asscalar
require
Joining arrays¶
concatenate(seq[, axis, out]) |
Join a sequence of arrays along an existing axis. |
stack(arrays[, axis, out]) |
Join a sequence of arrays along a new axis. |
dstack(arrays) |
Stack arrays in sequence depth wise (along third axis). |
vstack(arrays[, out]) |
Stack arrays in sequence vertically (row wise). |
column_stack
hstack
block
Splitting arrays¶
split(ary, indices_or_sections[, axis]) |
Split an array into multiple sub-arrays. |
hsplit(ary, indices_or_sections) |
Split an array into multiple sub-arrays horizontally (column-wise). |
vsplit(ary, indices_or_sections) |
Split an array into multiple sub-arrays vertically (row-wise). |
array_split
dsplit
Tiling arrays¶
tile(A, reps) |
Construct an array by repeating A the number of times given by reps. |
repeat(a, repeats[, axis]) |
Repeat elements of an array. |
Adding and removing elements¶
unique(ar[, return_index, return_inverse, …]) |
Find the unique elements of an array. |
delete
insert
append
resize
trim_zeros
Rearranging elements¶
reshape(a, newshape[, order, out]) |
Gives a new shape to an array without changing its data. |
flip(m[, axis, out]) |
Reverse the order of elements in an array along the given axis. |
roll(a, shift[, axis]) |
Roll array elements along a given axis. |
rot90(m[, k, axes]) |
Rotate an array by 90 degrees in the plane specified by axes. |
fliplr
flipud