РЕДАКТИРОВАТЬ: Если преобразовать время в дату и время без информации о датах, панды, очевидно, добавить дату фактического дня.
Если нужно еще несколько дней, проверьте это решение:
Идея заключается в создании последовательныхдата и время могут быть записаны, если время начинается с 0
:
df = df[['Timestamp']]
print (df)
Timestamp
0 00:08.3 <- first day
1 00:48.7
2 00:50.0
3 00:53.1
4 10:11.9
5 10:13.3
6 10:41.2
7 00:50.0 <- second day
8 00:53.1
9 10:42.5
10 10:43.9
11 00:07.5 <- third day
12 00:08.3
13 10:11.9
14 10:13.3
15 10:43.9
#convert to datetimes and get hours for test 0
df['h'] = pd.to_datetime(df['Timestamp']).dt.hour
#test first 0 for start of day
df['mask'] = df['h'].shift().ne(0) & df['h'].eq(0)
#create consecutive groups - starts by 1 if first time start by 0, else start by 1
df['g'] = df['mask'].cumsum()
#specify first day in origin parameter
df['days'] = pd.to_datetime(df['g'], origin='2016-01-01', unit='d')
#add to original Timestamps if HH:MM.SS
df['Timestamp1'] = df['days'] + pd.to_timedelta(df['Timestamp'].str.replace('\.',':'))
#add to original Timestamps if format without hours - MM:SS.SS
df['Timestamp2'] = df['days'] + pd.to_timedelta('00:' + df['Timestamp'])
print (df)
Timestamp h mask g days Timestamp1 \
0 00:08.3 0 True 1 2016-01-02 2016-01-02 00:08:03
1 00:48.7 0 False 1 2016-01-02 2016-01-02 00:48:07
2 00:50.0 0 False 1 2016-01-02 2016-01-02 00:50:00
3 00:53.1 0 False 1 2016-01-02 2016-01-02 00:53:01
4 10:11.9 10 False 1 2016-01-02 2016-01-02 10:11:09
5 10:13.3 10 False 1 2016-01-02 2016-01-02 10:13:03
6 10:41.2 10 False 1 2016-01-02 2016-01-02 10:41:02
7 00:50.0 0 True 2 2016-01-03 2016-01-03 00:50:00
8 00:53.1 0 False 2 2016-01-03 2016-01-03 00:53:01
9 10:42.5 10 False 2 2016-01-03 2016-01-03 10:42:05
10 10:43.9 10 False 2 2016-01-03 2016-01-03 10:43:09
11 00:07.5 0 True 3 2016-01-04 2016-01-04 00:07:05
12 00:08.3 0 False 3 2016-01-04 2016-01-04 00:08:03
13 10:11.9 10 False 3 2016-01-04 2016-01-04 10:11:09
14 10:13.3 10 False 3 2016-01-04 2016-01-04 10:13:03
15 10:43.9 10 False 3 2016-01-04 2016-01-04 10:43:09
Timestamp2
0 2016-01-02 00:00:08.300
1 2016-01-02 00:00:48.700
2 2016-01-02 00:00:50.000
3 2016-01-02 00:00:53.100
4 2016-01-02 00:10:11.900
5 2016-01-02 00:10:13.300
6 2016-01-02 00:10:41.200
7 2016-01-03 00:00:50.000
8 2016-01-03 00:00:53.100
9 2016-01-03 00:10:42.500
10 2016-01-03 00:10:43.900
11 2016-01-04 00:00:07.500
12 2016-01-04 00:00:08.300
13 2016-01-04 00:10:11.900
14 2016-01-04 00:10:13.300
15 2016-01-04 00:10:43.900