0
Numpy Array value replace with yesor no
In a numpy Array if it satisfying a condition then replace these value with yes otherwise replace with no with the help of np.where
3 Réponses
+ 1
Np.where is necessary
This code will work?
Arr=([2,4,6,7,8,9])
Ans=np.where( (arr%3 ==0 & arr%==0)=True ,"yes", "no")
Or
Ans=np.where( (arr%3 ==0 & arr%==0) ,"yes", "no")
+ 1
Yes, it will work. My regards.
0
Is it necessary to use np.where? You can write a function, for example:
def fun(x):
return 'yes' if condition else 'no'
Vectorize it using np.vectorize and apply to your array.