Divide an array into equal or sized sections.
Numeric.shape.split(input, sections, level = 0, method = 'equal')Divides the array into equal or sized sections.
- Parameters:
input: Array to divide into sectionssections: Number of sections or their sizeslevel: Axis along which the array is splitmethod: Splitting method applied to the array
- Returns: Array of section arrays
- NumPy: Covers
np.split,np.array_split,np.vsplit,np.hsplit,np.dsplitthrough a single Numerix method.
import Numeric from '@neabyte/numerix'
const parts = Numeric.shape.split([1, 2, 3, 4], 2)
console.log(parts)
// [[1,2],[3,4]]import Numeric from '@neabyte/numerix'
const parts = Numeric.shape.split([1, 2, 3, 4], [2, 3])
console.log(parts)
// [[1,2],[3],[4]]import Numeric from '@neabyte/numerix'
const parts = Numeric.shape.split([[1, 2, 3, 4], [5, 6, 7, 8]], 2, 1)
console.log(parts)
// [[[1,2],[5,6]],[[3,4],[7,8]]]import Numeric from '@neabyte/numerix'
const parts = Numeric.shape.split([1, 2, 3, 4, 5, 6], 3)
console.log(parts)
// [[1,2],[3,4],[5,6]]