更新时间:2023-12-01 14:29:58
你可以试着花几分钟时间处理一下
You can try of taking minutes and bin to it
uber = pd.DataFrame()
labels = [str(i)+':01-'+str(i+1)+':00' for i in range(59)]
uber['Time'] = {0: '0:11:00', 1: '0:17:00', 2: '0:21:00', 3: '0:28:00', 4: '0:33:00'}.values()
uber.Time = pd.to_timedelta(uber.Time)
pd.cut(uber.Time.dt.seconds/60,bins,labels=labels)
出:
0 10:01-11:00
1 16:01-17:00
2 20:01-21:00
3 27:01-28:00
4 32:01-33:00
Name: Time, dtype: category
Categories (59, object): [0:01-1:00 < 1:01-2:00 < 2:01-3:00 < 3:01-4:00 ... 55:01-56:00 < 56:01-57:00 < 57:01-58:00 < 58:01-59:00]