ndarray
basic operation
1 | from numpy import * |
creation
arange, random.rand, random.randint, linspace, ones, zeros, empty, logspace
slice
-
a[…, i]
… represent unspecified dim
-
np.split(a, N)
split a into evenly N parts
-
np.split(a, [])
split a at certain index
concat
- np.vstack(a, b)
- np.hstack(a, b)
- np.concatenate(a, b, axis = ?)
- np.stack(a, b) Note: Stack in a new dimension
- np.fliplr()
- np.flipud()
basic math operation
-
np.dot
Note: calculate dot product of two vectors
-
power
1 | from numpy import * |
random
1 | import python.random as random |
useful
- operation on mask ndarray
1 | a = np.arange(10) |
Numpy Cheatsheet
Those two are copied from BHu by me and the origin of which are shown in the pics.