如何在熊猫中将字符串转换为时间戳

Sam*_*ngh 1 datetime timestamp dataframe python-3.x pandas

我有以下数据集

    OPEN TIME  CLOSE TIME
0   09:44:00   10:07:00
1   10:07:00   11:01:00
2   11:05:00   13:05:00
Run Code Online (Sandbox Code Playgroud)

但是这里的时间戳是字符串格式,我如何将它们转换为时间格式?请帮我!

Ata*_*CSE 6

日期时间

df['Open'] = pd.to_datetime(df['OPEN TIME'],format= '%H:%M:%S' ).dt.time
df['Close'] = pd.to_datetime(df['CLOSE TIME'],format= '%H:%M:%S' ).dt.time
Run Code Online (Sandbox Code Playgroud)

  • .dt.time 位是什么? (2认同)