The below code does what you want. also, I made some changes to your code.
def some_fun(x):
if pd.isnull(x):
return 'something else'
else:
return 'something'
df['new_col'] = [some_fun(x) for x in df['date']]
unfortunately, np.isnat()
failed in my code. so I used pd.isnull()
instead according to this answer. if you think that'll work for you, use np.isnat()
.
Output:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…