I have a column called Pausetime and another one called Worktime.
Both of them are strings and look like this: "02:28:49".
I want to convert them from strings to date objects; however, keep the format %H%M%S
I am using the following line:
# define the format of the time columns
time_format = "%H:%M:%S"
# convert the time columns
df["Pausetime"] = pd.to_datetime(df["Pausetime"], format=time_format)
df["Worktime"] = pd.to_datetime(df["Worktime"], format=time_format)
print(df["Worktime"])
但是,输出不是传递的time_格式
1 1900-01-01 02:28:49
2 1900-01-01 04:47:45
3 1900-01-01 04:49:09
4 1900-01-01 02:46:47
Name: Worktime, dtype: datetime64[ns]
Any Tips on how to achieve this?
I am new to Pandas and kinda lost in this issue.
The reason is I am calculating the time later on in Excel, and apparently, it only works if the cell is date formatted.