I had a datetime column (as object type) in my Pandas dataframe. I broke the datetime column to two columns date and time and I transformed both using to_datetime to the following format with the following code:
df['Time'] = pd.to_datetime(df['Time'], format='%H:%M:%S').dt.time
df['Date'] = pd.to_datetime(df['Date'], format='%Y.%m.%d')
After the above code execution, I have the Date column of type Datetime and the Time column (e.g., 00:14:53) of type object - I don't know why not Datetime since I used to_datetime-
I want to break the time column to 4 categories/bins, 00:00:00 - 06:00:00 as category 1, then 06:00:00 to 12:00:00 and so on.
I tried different methods with the cut but all wrong.
What I am doing wrong, any help how to do this?
Thanks