Возможно использование альтернативы с Series.where
?
Образец :
df = pd.DataFrame({
'Effective Date':pd.date_range('2019-01-01', periods=6),
'Cancellations':['Yes'] * 4 + ['No'] * 2,
'Lapses':['yes'] * 2 + ['No'] * 4,
})
df['Termination_Date'] = df['Effective Date'].where((df['Cancellations'] == 'Yes') |
(df['Lapses'] == 'Yes'))
Или:
m = (df['Cancellations'] == 'Yes') | (df['Lapses'] == 'Yes')
df.loc[m, 'Termination_Date'] = df['Effective Date']
print (df)
Effective Date Cancellations Lapses Termination_Date
0 2019-01-01 Yes yes 2019-01-01
1 2019-01-02 Yes yes 2019-01-02
2 2019-01-03 Yes No 2019-01-03
3 2019-01-04 Yes No 2019-01-04
4 2019-01-05 No No NaT
5 2019-01-06 No No NaT