MoonNote

반응형
     

 

 

 

배열 분리(Array_split)

numpy.array_split(ary, indices_or_sections, axis=0)

 

Python split 함수 참조

 

배열다루기 | 배열 분리(Numpy.split)

배열 분리(Split) numpy.split(ary, indices_or_sections, axis=0) 배열을 여러개의 하위 배열로 분리합니다. ▪Parameters ‣ ary : 입력 배열, ‣ indices_or_sections : 'Integer'인 경우, 축을 따라 동일한 N개의 배열로 분

moonnote.tistory.com

 

TIP
 
 

차이점은 indices_or_sections이 정수 입력만 가능하며 축을 균등하게 분리하지 않음 !!

 


▪Parameters

     ‣  ary : 입력 배열,

     ‣  indices_or_sections : 정수 입력(Integer), 축을 따라 N개의 배열로 분리

   ‣    axis : 축 설정(optional)

 

 

 

     ‣  Returns : sub-arrays(list of ndarrays), 분리된 배열 반환

 

 

예제(Example)

<Example 01>

import numpy as np

x = np.arange(8.0)
output = np.array_split(x, 3)

print(output)

Result

[array([0., 1., 2.]), array([3., 4., 5.]), array([6., 7.])]

 

<Example 02>

import numpy as np

x = np.arange(9)
output = np.array_split(x, 4)

print(output)

Result

[array([0, 1, 2]), array([3, 4]), array([5, 6]), array([7, 8])]

 

Numpy 함수 모음

 

 

 

 

 

 

 

 

 

※ 이 글이 도움이 되었다면 "👆🏻구독"과 "🤍공감" 버튼을 클릭해주세요. 클릭 한번이 글 쓰는데 큰 힘이 됩니다.

공유하기

facebook twitter kakaoTalk kakaostory naver band