【发布时间】:2020-08-04 11:43:00
【问题描述】:
如果您能使用 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'] )
我使用代码 3 根据“外部名称”列中的字符串值“GBTICJE”将字符串值提取到“评论”列,如果不满足条件,则不会覆盖“评论”列中的现有字符串。
但是如何将代码 1 和 2 集成到代码 3 中?这样我就可以在执行初始代码 3 之前先根据 1 和 2 中的两个条件过滤数据帧?
有没有更好的方法来做到这一点?
【问题讨论】:
标签: python-3.x pandas numpy jupyter-notebook where-clause