I have a column in my dataset which represents a date in ms and sometimes its values is nan
(actually my columns is of type str
and sometimes its valus is 'nan'
). I want to compute the epoch in days of this column. The problem is that when doing the difference of two dates:
(pd.to_datetime('now') - pd.to_datetime(np.nan)).days
if one is nan
it is converted to NaT
and the difference is of type NaTType
which hasn't the attribute days
.
In my case I would like to have nan
as a result.
Other approach I have tried: np.datetime64
cannot be used, since it cannot take as argument nan
. My data cannot be converted to int
since int
doesn't have nan
.