Skip to main content

NumPy Array Operations Methods

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

NumPy Matrix Operations Methods

returns the sum of the diagonals of the matrix

compute the determinant of the given matrix

performs matrix multiplication in NumPy

creates a matrix from a 2-D array-like object

computes various matrix norms

fromstring() creates 1D array from raw binary/text

histogram() computes the histogram of the dataset

NumPy Array Creation Methods

creates an array with interval-based elements

creates new array of given shape filled with zeros

create evenly spaced array elements over interval

creates new array of given shape filled with ones

logspace() creates array with evenly spaced number

meshgrid() taken 1D arrays and returns 2D arrays

empty() creates new array without defining entries

copy() returns the copy of an array

full() creates an array filled with a given value

loadtxt() loads data from a text file

asarray() converts all array-like objects to array

diag() either forms or fetches diagonal of array

eye() creates 2D array with 1s(on diagonal) and 0s

frombuffer() interprets a buffer as a 1D array

NumPy Matrix Operations Methods

std() computes standard deviation of given numbers

percentile() computes q-th percentile of the data

max() returns the largest element of an array

min() returns the smallest element of an array.

average() computes the weighted average of array

computes cross-correlation of two 1D sequences

median() finds the median along specified axis.

var() computes the variance along specified axis

quantile() computes the q-th quantile of the data

nanmean() computes arithmetic mean, ignoring NaNs

computes range of values(maximum-minimum) in array

estimate covariance matrix, given data and weights

mean() computes arithmetic mean of a given set

NumPy Matrix Operations Methods

limits the values in an array to a specified range

returns rounded elements

calculate the sum of array elements

raise the elements of an array to specified power

calculate the cumulative sum of array elements

perform element-wise multiplication of two arrays

computes square root of each element in an array

round down elements to nearest smallest integer

computes the absolute value

calculate the difference of consecutive elements

perform element-wise division of the elements

computes the element-wise sine of array

computes squares of an array's elements

perform element-wise addition

finds minimum value between corresponding elements

finds maximum value between corresponding elements

computes the element-wise arc tangent

computes the cross product of two vectors

determines the sign of each element in an array

calculates base-10 logarithm of array elements

computes arctangent (inverse tangent) of an array

compute the maximum value in an array

computes arccosine (inverse cosine) of an array

computes the element-wise cosine of an array

performs element-wise subtraction of two arrays

rounds up each element in an array

compute the minimum value

compute definite integral using trapezoidal rule

computes the arcsine (inverse sine) of array

rounds the elements of an array

compute the element-wise tangent

calculate the product of array elements

calculate the hyperbolic tangent

calculates the hypotennumber

calculate the natural logarithm of the elements

calculate the exponential values of the elements