I have an array like so:
arr = np.array([1, 2, 3, 4, -5, -6, 3, 5, 1, -2, 5, -1, -1, 10])
I want to get rid of all negative values, and split the array at each index where there was a negative value. The result should look like this:
split_list = [[1, 2, 3, 4], [3, 5, 1], [5], [10]]
I know how to do this using list comprehension, but since the array can get quite large and I have to do the calculation many times, I want to find a solution using numpy. I found this https://www.geeksforgeeks.org/python-split-list-into-lists-by-particular-value/, which I can use to split the array where there are negative values, but I can't simultaneously remove them.
if len(sublist) > 0 and sublist[0] > 0?