Reputation: 65
I would really appreciate it if you could help me with this task using Jupyter Notebook.
1 store = vat['Sum of VAT'].notnull()
2 store1 = vat['Comment'] == "VAT"
3 vat['Comment'] = np.where(vat['External name'] == 'GBTICJE','Reverse charge + IC',vat['Comment'] )
I was using code 3 to extract a string value to column ‘Comment’ based on the string value ‘GBTICJE’ in column ‘External name’ without overwriting the existing strings in column ‘Comment’ if the condition was not met.
But how do I integrate code 1 & 2 into code 3? So that I'm able to first filter the data frame based on the two conditions in 1 & 2 before performing the initial code 3?
Is there a better way to do this?
Upvotes: 0
Views: 400
Reputation: 1125
Here is what I suggest :
vat.loc[(vat['Sum of VAT'].notnull()) &
(vat['Comment'] == "VAT") &
(vat['External name'] == 'GBTICJE'), "Comment"] = 'Reverse charge + IC'
Upvotes: 1