Suppose I have this NumPy array:
a = np.array([0, 3, 5, 5, 0, 10, 14, 15, 56, 0, 12, 23, 45, 23, 12, 45,
0, 1, 0, 2, 3, 4, 0, 0 ,0])
<
You can get the indices of zeros with np.where:
zeros = np.where(a == 0)[0]
And iterate over every pair to slice the array:
[a[i+1:j] for i, j in zip(zeros, zeros[1:]) if len(a[i+1:j])>0]
Out[46]:
[array([3, 5]),
array([10, 14, 15, 56]),
array([12, 23, 45, 23, 12, 45]),
array([1]),
array([2, 3, 4])]