I am trying to create a list of date time in python using pandas. I want something like:
2023-05-10_00:00:00
2023-05-10_01:00:00
2023-05-10_02:00:00
.....
.....
2023-05-10_23:00:00
So basically I want data with datetime with 1 hour increment. I tried the following
dt = pd.to_datetime('2023-05-10',format='%Y-%m-%d')
print(dt)
which gives me the following, and it is not exactly what I am looking for
2023-05-10 00:00:00
I was also thinking of creating a list or array with just the date 2023-05-10 and another array with only time with 1-hr increment, and then paste them together with a separator _. I am not sure how to do this in Python.
Thanks in advance.
>Solution :
i make 3 data for example
pd.date_range('2023-05-10', periods=3, freq='H').strftime('%Y-%m-%d_%H:%M:%S')
output:
Index(['2023-05-10_00:00:00', '2023-05-10_01:00:00', '2023-05-10_02:00:00'], dtype='object')