Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Numpy
import numpy as np
a = np.arange(6).reshape((3,2))
print(a)
#[Output]:
#array([[0, 1],
# [2, 3],
# [4, 5]])
## amin() function to find minimum in array.
## Similarly we can go for amax() to find maximum
## Return minimum along flattened array.
print(np.amin(a))
#[Output]:
#0
## Minimum along columns
np.amin(a,axis=0)
#[Output]:
#array([0, 1])
##Minimum along rows
np.amax(a,axis=1)
#[Output]:
#array([1, 3, 5])
## percentile() function to find percentile along the specified axis
np.percentile(a,q=0)
#[Output]:
#0.0
print(np.percentile(a,q=50))
print(np.percentile(a,q=50,axis=0))
#[Output]:
#2.5
#[2. 3.]
np.percentile(a,q=100)
#[Output]:
#5.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.