Mar-01-2024, 08:54 AM
I have date/time data in .txt file likes below format:
2024-2-27, 0:0:0 2024-2-27, 3:7:2 2024-2-27, 4:11:3 2024-2-27, 6:3:5 2024-2-27, 13:10:6 2024-2-27, 20:20:7 2024-2-27, 21:30:9 2024-2-27, 22:40:10 2024-2-27, 23:50:12I want to load that use numpy.loadtxt() and convert to 'datetime64' type, but 'datetime64' type require string format likes below:
numpy.array(['2020-02-27T15:23:07'], dtype = 'datetime64[s]')so I must fill some '0', and concatenate date and time use 'T'?
# fill '0' 2024-02-27, 00:00:00 2024-02-27, 03:07:02 2024-02-27, 04:11:03 2024-02-27, 06:03:05 2024-02-27, 13:10:06 2024-02-27, 20:20:07 2024-02-27, 21:30:09 2024-02-27, 22:40:10 2024-02-27, 23:50:12 # concatenate use 'T' 2024-02-27T00:00:00 2024-02-27T03:07:02 2024-02-27T04:11:03 2024-02-27T06:03:05 2024-02-27T13:10:06 2024-02-27T20:20:07 2024-02-27T21:30:09 2024-02-27T22:40:10 2024-02-27T23:50:12Is it have simply way to do that?