Could you please help me generating third column from the table using Python? I tried with numpy.where option, but I am unable to get the desired output.
My table:
I have tried the code
db['Condition'] = numpy.where(db.Value <50, 'Less than 50', db.Value <100, 'Less than 100','more than 100').
Here, db refers to data base name. And the error message I am getting
TypeError: where() takes at most 3 arguments (5 given)
According to numpy.where documentation, it only takes 3 arguments, condition and x (if true),y (if false) array_like. To get your desired output:
db['Condition'] = numpy.where(db['Value'] < 50, 'Less than 50', numpy.where(db['Value']<100, 'Less than 100','More than 100'))