Q: Convert Time to Integer I have a column in a dataframe that contains time in the below format.
Dataframe: df
column: time
value: 07:00:00, 13:00:00 or 14:00:00

The column will have only one of these three values in each row. I want to convert these to 0, 1 and 2. Can you help replace the times with these numeric values?
Current: 
df['time'] = [07:00:00, 13:00:00, 14:00:00]

Expected:
df['time'] = [0, 1, 2]

Thanks in advance.

A: You can use map to do this:
import datetime

mapping = {datetime.time(07,00,00):0, datetime.time(13,00,00):1, datetime.time(14,00,00):2}
df['time']=df['time'].map(mapping)


A: One approach is to use map
Ex:
val = {"07:00:00":0, "13:00:00":1, "14:00:00":2}

df = pd.DataFrame({'time':["07:00:00", "13:00:00", "14:00:00"] })
df["time"] = df["time"].map(val)
print(df)

Output:
   time
0     0
1     1
2     2

