s = pd.to_datetime(temp_result_df['DateCol'], errors='coerce') + pd.Timedelta(1, 'd')
temp_result_df['NewDateCol'] = s.dt.strftime('%d/%m/%Y').replace('NaT','Employee Not Found')
print (temp_result_df)
ID DateCol NewDateCol
0 1 26/06/2017 27/06/2017
1 2 Employee Not Found Employee Not Found
对于缺少的值,最好使用带有} :
NaT
的列中的datetimes
-使用带有Timedelta
或Day
偏移量的^{如果需要原始数据这样的字符串,则需要^{} 和
replace
:相关问题 更多 >
编程相关推荐