I am dealing with hourly data in which the date is stored in 4 different arrays, one for day, month, year, and hour. I am running a for-loop to rather store these dates as strings with this format: '01/01/1946 0'
My code looks something like this:
import numpy as np
from datetime import datetime as dt
import matplotlib.dates as mdates
for nn in range(nnn):
y1 = int(yr[nn])
m1 = int(mon[nn])
d1 = int(day[nn])
h1 = int(hr[nn])
#In the the last string we are specifying the format
datenow = dt.strptime(str(m1)+'/'+str(d1)+'/'+str(y1) + ' '+ str(h1) , '%m/%d/%Y %H').date()
ndaten = datenow.toordinal()
allnewdate[nn] = ndaten
When I check allnewdate
with mdates.num2str(allnewdates)
it appears that all hours are defined as 0 at each point instead of parsing through the 23 hours of the day.
What might be wrong?