Created Insert Time MatchKey In PrevIoUs New Type
18593 2016-08-12 2018-02-19 LXGS090393APIN040640 No New Existing
5517 2016-08-12 2018-02-19 LIN380076CI166203726 No New Existing
2470 2018-02-12 2018-02-19 CI164414649APIN160672 No New Existing
13667 2016-08-12 2018-02-19 LIN257400APIN015446 Yes New Existing
10998 2016-08-12 2018-02-19 LXSV225786APIN158860 Yes New Existing
20149 2016-08-12 2018-02-19 LIN350167APIN158284 Yes New Existing
20143 2016-08-12 2018-02-19 LIN350167APIN161348 Yes New Existing
30252 2016-08-12 2018-02-19 LXGS120737APIN153339 Yes New Existing
12583 2016-08-09 2018-02-19 WIN556410APIN157186 Yes New Existing
28591 2018-05-03 2018-02-19 CI195705185APIN009076 No New Created
我想以某种方式替换“新类型”列中的值,如果条件失败,该函数将不执行任何操作:
current['New Type'] = np.where(current['In PrevIoUs']=='Yes','In PrevIoUs',pass)
但显然会导致语法错误,因为np.where()无法处理传递:
File "<ipython-input-9-7f68cda12cbe>", line 1
current['New Type'] = np.where(current['In PrevIoUs']=='Yes','In PrevIoUs',pass)
^
SyntaxError: invalid Syntax
有什么办法可以达到相同的目的?
解决方法:
仅返回该列而不是传递,这与条件为False时不执行任何操作相同:
current['New Type'] = np.where(current['In PrevIoUs']=='Yes','In PrevIoUs',current['New Type'] )
或者,您可以掩盖这些行:
current['New Type'] = current.loc[current['In PrevIoUs']=='Yes', 'In PrevIoUs']
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。