Reputation: 45
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").
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().'
Upvotes: 0
Views: 43
Reputation: 535
What you're looking for is this;
import numpy as np
liftinput['DNVGL Shape'] = np.where(liftinput['LENGTH (m)'].gt(liftinput['DEPTH d (m)'].mul(3)), 'Flat Long Shaped', 'Box/Round Shaped')
This is probably the most efficient way that you can do what you're trying to do.
Upvotes: 1