Math/Statistics Computation
Transposing Arrays
Inner product
Mean
The function .mean()
can be used to calculate the percent of array elements that satisfies a certain condition.
row/column mean in 2-D arrays
In a two-dimensional array, you may want the mean of just the rows or just the columns. The NumPy .mean()
function can be used to find these values. To find the average of all rows, set the axis parameter to 1. To find the average of all columns, set the axis parameter to 0.
Sorting
NumPy .sort()
function takes a NumPy array and returns a different NumPy array, this one containing the same numbers in ascending order.
Percentiles and Quartiles
NumPy .percentile
function accepts a NumPy array and percentile value between 0 and 100. The function returns the value of the array element at the percentile specified.
NumPy .percentile()
function can calculate the first, second and third quartiles of an array. These three quartiles are simply the values at the 25th, 50th, and 75th percentiles, so those numbers would be the parameters, just as with any other percentile.
Last updated
Was this helpful?