Last active
February 15, 2019 14:38
-
-
Save Robofied/2d8b38e398562a2da6d847c1a68dd608 to your computer and use it in GitHub Desktop.
Numpy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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