我尝试创建列终止日期。但只有当标志“取消”或“失效”设置为“是”时,列终止日期才应包含生效日期,否则为空。对于这三种方法,我收到以下错误消息
df['Termination_Date'] = np.where((df['Cancellations'] == 'Yes') | (df['Lapses'] == 'Yes'), df['Effective Date'])
ValueError: either both or neither of x and y should be given
df['Termination_Date'] = np.where((df['Cancellations'] == 'Yes') | (df['Lapses'] == 'Yes'), df['Effective Date'], "")
TypeError: invalid type promotion
df['Termination_Date'] = np.where((df['Cancellations'] == 'Yes') | (df['Lapses'] == 'Yes'), df['Effective Date'], np.nan)
TypeError: invalid type promotion
谢谢
使用^{} :
或^{}
我们也可以用^{} 检查
您可以使用.loc索引:
是否可以与^{} 一起使用替代方案
样本:
或:
相关问题 更多 >
编程相关推荐