Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
<pre lang="Python">


xarr = np.array([1,2,3,4,5.5,6.6,7.7,8.8])

yarr = np.array([1.1,2.2,3.3,4.4,5,6,7,8])

cond = np.array([False,False,False,False,True,True,True,True])

result = np.where(cond,xarr,yarr)

and 


result = np.where(xarr,yarr,cond)


What I have tried:

I am getting different output.
Posted
Updated 16-Sep-21 1:19am
v2
Comments
Richard MacCutchan 16-Sep-21 3:55am    
That is because you have two different statements. But if you want a detailed answer then you need to provide considerably more detail about what your code is doing, what are its inputs, and what are its outputs. Just posting two random lines of code with no context is no help to anyone here.
Richard MacCutchan 16-Sep-21 7:22am    
You were given the link to the documentation page earlier today. Have you actually looked at it? It clearly states that the first parameter to the where function is the condition clause. So if you change the order of the parameters you will get different results.

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900