Home:ALL Converter>Apply condition to multiple arrays

Apply condition to multiple arrays

Ask Time:2018-08-18T21:44:20         Author:zxdawn

Json Formatter

How to apply a same condition to multiple arrays?

import numpy as np

a = np.array([1,2,3,4,5])
b = np.array([2,3,4,5,6])
c = np.array([5,6,7,8,9])
a,b = a[c>6],b[c>6]
print (a,b)

Like this, I want to filter out elements in 'a' and 'b' using the same filter, then replace the original value. Although this code works fine, it will be very long if I want to apply this filter to many arrays.

Author:zxdawn,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/51909310/apply-condition-to-multiple-arrays
yy