I want to use list comprehension instead of using append method because it make the code runs faster however when it is a numpy array it doesn't work.
import numpy as npa = np.array([1, 2 , 4])b = np.array([6, 5 , 2])A = []B = []for i in range(0, 3): if a[i] > value1 and b[i] > value1: A.append(a[i]) B.append(b[i])
for example I am trying something like this:
A = [a[i] for i in range(1, 3) if a[i] > value1 and b[i] > value1]
and finally is there a way to define a general function that append elements from an array of numbers in a new list based on if conditions like the mentioned example.