import datetime as dt
import pandas as pd
df = pd.DataFrame([[1, '16:45'],
[2, '21:03:39']], columns=['x1', 'time_string'])
df['time'] = pd.to_datetime(df['time_string']).apply(lambda t: dt.time(t.hour, t.minute, t.second))
# Output these to show it works
df.head()
df['time'].apply(lambda x: type(x))
1条答案
按热度按时间eoxn13cs1#
像这样的东西怎么样?
返回以下内容: