- ndarray.ndim
Number of array dimensions.
c=np.array([
[[1,2,3],[3,4,4]],
[[5,6,6],[7,8,8]]
])
print(c.ndim)
print(c.shape)
>>>
3
(2, 2, 3)
- ravel
It returned 1-d array.
np.array([[1,2,3],[4,5,6]]).ravel()
>>>
array([1, 2, 3, 4, 5, 6])
Same as below.
np.array([[1,2,3],[4,5,6]]).reshape(-1)
>>>
array([1, 2, 3, 4, 5, 6])
- permutation
It returns the permutated range.
np.random.permutation(10)
>>>
array([7, 1, 8, 2, 4, 6, 9, 0, 3, 5])
- clip
If an interval of [0, 1] is specified, values smaller than 0 become 0, and values larger than 1 become 1.
np.clip(np.arange(10),2,5)
>>>
array([2, 2, 2, 3, 4, 5, 5, 5, 5, 5])
- subtract
subtract(x,y) : x-y
x1=np.arange(9.0).reshape((3,3))
x1
>>>
array([[0., 1., 2.],
[3., 4., 5.],
[6., 7., 8.]])
x2=np.arange(3.0)
x2
>>>
array([0., 1., 2.])
np.subtract(x1,x2)
>>>
array([[0., 0., 0.],
[3., 3., 3.],
[6., 6., 6.]])
'Analyze Data > Python Libraries' 카테고리의 다른 글
numpy-random (0) | 2022.12.29 |
---|---|
numpy-empty, where, allclose, dot, argsort, corrcoef, astype, nan, hstack, argmax (0) | 2022.12.07 |
regular expression (0) | 2022.04.26 |
collections-Counter, most_common, FreqDist, defaultdict (0) | 2022.03.04 |
pandas-5. json_normalize (0) | 2021.10.25 |