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

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

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 Likes

Thank You @A.Malathi

Thanks a lot @A.Malathi

© Copyright 2013-2019 Analytics Vidhya