Note
Numpy (16) 본문
728x90
How to swap two columns in a 2d numpy array?
# Input
arr = np.arange(9).reshape(3,3)
arr
# Solution
arr[:, [1,0,2]]
# output
array([[1, 0, 2],
[4, 3, 5],
[7, 6, 8]])
'Numpy' 카테고리의 다른 글
Numpy (18) (0) | 2022.08.09 |
---|---|
Numpy (17) (0) | 2022.08.08 |
Numpy (15) (0) | 2022.08.06 |
Numpy (14) (0) | 2022.08.05 |
Numpy (13) (0) | 2022.08.03 |
Comments