I am trying to read some date info from Excel using openpyxl which returns them as datetime.datetime. I need to resample the data and then plot the resampled times using matplotlib. I would like an array of dates starting at tmin, incremented by 30.0 days.
The code stub is
import numpy as np
import datetime
vals = [
datetime.date.fromisoformat('2004-06-01'),
datetime.date.fromisoformat('2004-07-01'),
datetime.date.fromisoformat('2004-08-01'),
datetime.date.fromisoformat('2004-09-01'),
datetime.date.fromisoformat('2004-10-01'),
datetime.date.fromisoformat('2004-11-01')]
xtim = np.array(vals)
tmin = np.min(xtim)
ytim = np.arange(0.0, 150.0, 30.0)
tnew = tmin + ytim.astype('timedelta64[D]')
Unfortunately, this gives me the error message
UFuncTypeError: ufunc 'add' cannot use operands with types dtype('O') and dtype('<m8[D]')