Home > Software engineering >  please am trying to make a condition of if x and y is ..... do this or that
please am trying to make a condition of if x and y is ..... do this or that

Time:10-12

if UpMove > DownMove and UpMove > 0, then DM = UpMove, else DM = 0

and this is what I have been trying

df_move[" DI"] = np.where(df_move["upmove"] > df_move["downmove"] & 0 , df_move["upmove"], 0 )

and I am get this error msg

TypeError: Cannot perform 'and_' with a dtyped [float64] array and scalar of type [bool]

PLEASE what will I do

CodePudding user response:

You are using np.where function wrong. Try this:

df_move[" DI"] = np.where((df_move["upmove"] > df_move["downmove"]) & (df_move["upmove"] > 0), df_move["upmove"], 0 )
  • Related