Divide arrays with split(), array_split(), vsplit(), and hsplit().
Splitting divides an array into multiple smaller sub-arrays along an axis. `np.array_split` allows unequal division without raising errors.
Splitting is slicing a loaf of bread into equal sandwich portions or dividing a deck of cards among players.
`np.split()` requires elements to divide equally. `np.array_split()` handles unequal splits gracefully by adjusting partition sizes.
train, val, test = np.array_split(data, 3)np.split(np.arange(10), 3) # ValueError: cannot divide 10 by 3 equallynp.array_split(np.arange(10), 3)`np.split` throws an error if size is not divisible. Use `np.array_split` for uneven division.
Solve the objective below using NumPy vectorized syntax
Create `arr = np.array([10, 20, 30, 40, 50, 60])`, split into 2 parts with `np.split(arr, 2)`, and print part 0.
[10 20 30]