Answer the question
In order to leave comments, you need to log in
How to display the difference in date and time in a separate column?
There are tabular data:
table = pd.DataFrame({
'user': ['Steve', 'Steve', 'Steve', 'Jack', 'Jack', 'Jack'],
'date': ['02.01.2018', '04.01.2018', '07.01.2018', '02.01.2018', '03.01.2018', '07.01.2018'],
'time': ['00:05:07', '00:06:14', '00:08:36', '00:14:51', '00:19:18', '00:31:24']
})
t1 = pd.to_datetime(0)
for i in table['datetime']: #я объединил колонки date и time, но пропадали секунды
t2 = pd.to_datetime(i)
table['difference'] = pd.Timedelta(t2 - t1)
t1 = t2
:4: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instea
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question