numpy.vsplit(ary, indices_or_sections)
Python split 함수 참조
배열다루기 | 배열 분리(Numpy.split)
배열 분리(Split) numpy.split(ary, indices_or_sections, axis=0) 배열을 여러개의 하위 배열로 분리합니다. ▪Parameters ‣ ary : 입력 배열, ‣ indices_or_sections : 'Integer'인 경우, 축을 따라 동일한 N개의 배열로 분
moonnote.tistory.com
차이점은 vsplit은 axis=0에 대해 동등하게 배열을 분리(2D 배열 이상 사용 가능)
▪Parameters
‣ ary : 입력 배열,
‣ indices_or_sections : 정수 입력(Integer), 축을 따라 N개의 배열로 분리
‣ Returns : sub-arrays(list of ndarrays), 분리된 배열 반환
<Example 01>
Copy import numpy as np x = np.arange(16.0).reshape(4, 4) output = np.hsplit(x, 2) print('x 배열 :\n', x) print('1번째 split 배열 :\n', output[0]) print('2번째 split 배열 :\n', output[1])
x 배열 : [[ 0. 1. 2. 3.] [ 4. 5. 6. 7.] [ 8. 9. 10. 11.] [12. 13. 14. 15.]] 1번째 split 배열 : [[0. 1. 2. 3.] [4. 5. 6. 7.]] 2번째 split 배열 : [[ 8. 9. 10. 11.] [12. 13. 14. 15.]]
<Example 02>
Copy import numpy as np x = np.arange(8.0).reshape(2, 2, 2) output = np.vsplit(x, 2) print('x 배열 :\n', x) print('1번째 split 배열 :\n', output[0]) print('2번째 split 배열 :\n', output[1])
x 배열 : [[[0. 1.] [2. 3.]] [[4. 5.] [6. 7.]]] 1번째 split 배열 : [[[0. 1.] [2. 3.]]] 2번째 split 배열 : [[[4. 5.] [6. 7.]]]
Numpy 함수 모음
※ 이 글이 도움이 되었다면 "👆🏻구독"과 "🤍공감" 버튼을 클릭해주세요. 클릭 한번이 글 쓰는데 큰 힘이 됩니다.
* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.