I have a list of arrays with variable length. I have something like that:
a=[np.array([0, 3, 4]), np.array([1, 8]), np.array([2, 5, 7]), np.array([6])]
And would like to extract from all arrays that contain more than one value all values but the first one. It is quite straight forward to do it in a for-loop but I would highly appreciate to know how to do it without a for loop to save time. My for-loop is like that:
duplicate_pos = []
for i in range(len(a)):
if len(a[i]) > 1:
duplicate_pos.append(a[i][1:])
Thx a lot.
PS: Even though this is the first question I ever ask here, stackoverflow is my daily science companion since I started my PhD several years ago. Thx to this amazing community.
forloop, it will save you time?...Did you try to profile it?numpytasks without a loop is a very common type of SO question. It belongs here.