Instantly share code, notes, and snippets.

# RobofiedRobofied

• Sort options
Last active Feb 15, 2019
Numpy
View numpy_statistical_functions1.py
 import numpy as np a = np.arange(6).reshape((3,2)) print(a) #[Output]: #array([[0, 1], # [2, 3], # [4, 5]])
Created Feb 15, 2019
Numpy
View numpy_mathematical_functions2.py
 print(np.cos(np.deg2rad(np.array((0.,30.,45.))))) #[Output]: #array([1. , 0.8660254 , 0.70710678])
Created Feb 15, 2019
Numpy
View numpy_mathematical_functions1.py
 import numpy as np ## 1. np.sin() print(np.sin(np.pi/2.)) #[Output]: #1.0 """In this we are taking an array of angles in degree and calculating the sine of that, so we are converting them to radians first"""
Created Feb 15, 2019
Numpy
View numpy_array_manipulation2.py
 ## 1. moveaxis routine import numpy as np x = np.zeros((3, 4, 5)) ## In this all the elements shape gets shifted in the direction of source to destonation, so for this example ## it is just like cyclic rotation in clockwise direction. print(np.moveaxis(x, 0, -1).shape) #[Output]:
Created Feb 15, 2019
Numpy
View numpy_array_manipulation1.py
 import numpy as np a = np.arange(6) print(a) #[Output]: #[0 1 2 3 4 5] ## 1. Reshaping a.reshape(2,3)
Created Feb 15, 2019
Numpy
View numpy_iterating_over_arrays2.py
 ## Here order doesn't matter a = np.arange(6).reshape(2,3) for x in np.nditer(a, order='F'): print (x,end=",") #[Output]: #0,3,1,4,2,5,
Created Feb 15, 2019
Numpy
View numpy_iterating_over_arrays1.py
 import numpy as np a = np.arange(6).reshape(2,3) for x in np.nditer(a): print (x,end=",") #[Output]: #0,1,2,3,4,5,
Created Feb 15, 2019
Numpy