I have a DataFrame where I want to change the value of the first column if some other columns have been populated.
dataprofile = {'profile_id': [1],'calcrule_id':[2], 'deductible1': [1],'deductible2': [0], 'deductible3':[0],'attachment': [0], 'limit': [2], 'share1':[2],'share2':[0],'share3':[0]}
dfprofile = pd.DataFrame(dataprofile)
#I would like to change the value of calcrule_id only if some other columns have been populated, and would like to nest this.
#What is the best way to go about this?
dfprofile['calcrule_id'] = np.where(dfprofile['deductible1']>=0,'1','1')
If deductible 1, limit and attachment have been populated then I would like to change 'calcrule_id' value and so fourth if share has been populated I would like a different value in calcrule_id
I'm not too sure how to go about the if statement if someone could help with an example, thanks in advance .
Aucun commentaire:
Enregistrer un commentaire