Numpy splitting 2

PHOTO EMBED

Mon Jan 24 2022 00:28:33 GMT+0000 (Coordinated Universal Time)

Saved by @ask4med #python

import numpy as np

arr = np.array([1, 2, 3, 4, 5, 6])

newarr = np.array_split(arr, 3)

print(newarr)

###
arr2 = np.array([1, 2, 3, 4, 5, 6])

newarr = np.array_split(ar2r, 4)

print(newarr)
content_copyCOPY

We also have the method split() available but it will not adjust the elements when elements are less in source array for splitting like in example above, array_split() worked properly but split() would fail.