My csv input file sometimes has excel serial numbers in the date field. I am using the following code as my input file should never contain dates prior to 01/2000. However, this solution is quite time consuming and I am hoping to find a better solution. Thank you.
def DateCorrection(x):
if pd.to_datetime(x) < pd.to_datetime('2000-01-01'):
return pd.to_datetime(datetime.fromordinal(datetime(1900, 1, 1).toordinal() + int(x) - 2))
else:
return pd.to_datetime(x)