I want to compare dates with NaNs included.
I used np.nanmin because this function excludes NaNs. However, this does not seem to work with dates.
I could write an apply() function, but because of the size of the dataset I would rather like to use a numpy-function. Any suggestions?
df = pd.DataFrame(np.array([[dt.datetime(2017, 1, 1, 0, 0),
dt.datetime(2017, 2, 1, 0, 0)],dt.datetime(2017, 3, 1, 0, 0), np.nan]]),
columns=['date1', 'date2'])
np.nanmin([df['date1'], df['date2']], axis=0)
I expect:
['2017-01-01', '2017-02-01']
I got:
ValueError: cannot convert float NaN to integer