How to Resolve Python Error: cannot compare a dtyped [int64] array with a scalar of type [bool]

python

#1

Hey all,
I want to create a new column ,which is based on the two condition,

Can any one tell what is wrong with the code, and what is the right code.

Input:

Dataset[“Req_Qty”] = np.where(Dataset[“Type”]==“TAB” & Dataset[“Value”]>=100,“100” , “False”)

Error:

TypeError: cannot compare a dtyped [int64] array with a scalar of type [bool]

Thank You


#2

need a parenthesis before and after the AND operator.
np.where(Dataset[“Type”]==“TAB”) & (Dataset["Value]>=100)])

Creating a new column depends on what the above code returns, if the condition is true!


#3

Thank You @A.Malathi