Hi folks, I look all over SO and google and can't find anything like it ...
I have a dataframe x (essentially consisting of one row and 300 columns) and another dataframe y with the same size but with different data. I would like to change x so that it is 0 if it has a different sign for y And x itself is not equal to 0, otherwise leave it as it is. so this requires using np.where with several conditions. However, in the examples of several conditions, I saw that everyone uses scalars, and when I use the same syntax, it does not seem to work (the installation ends β everything is to zero, without errors). I'm worried about link assignment issues hidden somewhere else (y - x after the offset, but how much can I judge that this code does not exist above) any ideas?
The code I'm trying to debug is:
tradesmade[i:i+1] = np.where((sign(x) != sign(y)) & (sign(x) != 0), 0, x)
which returns a bunch of zeros. I also tried
tradesmade[i:i+1][(sign(x) != sign(y)) * (sign(x) != 0)] = 0
but it doesnβt work either. I was in this for hours and to complete loss. please, help!
source share