Aug-07-2020, 02:27 AM
Thanks, it worked!
Out of curiosity, here is a little test I did comparing the execution time. It appears the NumPy method is 75x faster than looping. Do, you know what makes NumPy fast? Does it store the array in some efficient manner or something else?
Out of curiosity, here is a little test I did comparing the execution time. It appears the NumPy method is 75x faster than looping. Do, you know what makes NumPy fast? Does it store the array in some efficient manner or something else?
import time input = np.arange(4*10**7).reshape((10**7, 4)) # First method: Using NumPy start_time = time.time() print(input[(-1000 < input[:, 2]) & (input[:, 2] < 10000)]) print(time.time()-start_time) start_time = time.time() # Second method: Without NumPy diff = [] for row in range(10**7): if -1000 < arr[row, 2] < 10000: diff.append(arr[row, :]) print(diff) print(time.time()-start_time)