samedi 6 mars 2021

New column on Pandas with an if statment

I am trying to recreate the blue side of the table where the equation for dnvgl shape on excel is (=IF('LENGTH (m)'>(3*DEPTH d (m)),"Flat Long shaped","Box/round shaped").

enter image description here

I tried to do this on pandas using this formula.

liftinput['DNVGL Shape']= ('Flat Long Shaped' if liftinput['LENGTH (m)'] > (3*liftinput['DEPTH d (m)']) else 'Box/Round Shaped')

I got this error - 'The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().'

Aucun commentaire:

Enregistrer un commentaire