I have the following Dataframe:
Now i want to convert the column "ABZEIT" to time format. So the first rows would be:
13:05 15:40 14:20 16:30 07:40 12:05 17:15
I have the following Dataframe:
Now i want to convert the column "ABZEIT" to time format. So the first rows would be:
13:05 15:40 14:20 16:30 07:40 12:05 17:15
A solution that first defines a to_time()
function then apply it to the dataframe by using map()
.
from datetime import time
def to_time(t: int) -> time:
t = f"{t:04}" # add the leading zero if needed
return time(int(t[:2]), int(t[2:]))
df["ABZEIT"] = df["ABZEIT"].map(to_time)