i have a pandas dataframe df:
id value mins
1 a 12.4
2 u 14.2
3 i 16.2
3 g 17.0
i have a datetime.datetime variable:
current_time = datetime.datetime(2018, 1, 2, 14, 0, 34, 628481)
i want to add new column in my df 'total_time'
such that for every row it add the delta value mins in current_time.
id value mins total_time
1 a 12.4 current_time+timedelta(minutes = 12.4)
2 u 14.2 and
3 i 16.2 so
3 g 17.0 on... for every row
i tried:
df['total_time' = current_time+timedelta(minutes = df['mins'].item())
but i got an error:
can only convert an array of size 1 to a Python scalar
Is there any other way of doing this?
i'm using datetime.datetime package