Skip to main content

NumPy Array Operation Methods

NumPy provides methods to reshape, join, split, sort and search arrays.

Gives a new shape to an array

where() returns indices of an array that are True

transpose() swaps the axes of the given array

concatenate() joins arrays elements together

vstack() stacks the input arrays vertically

append() appends the values at the end of an array

sort() method sorts an array in ascending order

shape() method returns the shape of an array

ravel() flattens array without changing its data

repeat() repeats the elements of the array

hstack() stacks the arrays horizontally

stack() joins a sequence of arrays along new axis

argmax() returns the index of the largest element

roll() shifts array elements by specified times

tile() constructs an array by repeating arrays

argsort() returns indices that sorts an array

squeeze() removes the dimensions with size 1

argmin() returns index of smallest array element

insert() adds the values at specified indices

nonzero() finds indices of elements that aren't 0

returns indices of non-zero elements as 2-D array

delete() deletes the values at specified indices

flip() reverses the order of the elements

dstack() stacks the sequence of arrays depthwise

flatten() flattens array without changing its data

astype() converts an array to a specified datatype

tolist() converts a NumPy array to a Python list

pad() adds a value around array axis

split() splits an array into many sub-arrays

applies function to axis of nd arrays,avoids loops

apply a function repeatedly over multiple axes