I have some values in a pandas df that are positive and negative ints, and I want to convert them to timedeltas so I can put them into a DurationField in a Django model.
date dep_time dep_delay arr_time arr_delay cancelled carrier \
103992 2014-05-11 10:13:00 -2 12:47:00 -13 0 B6
103993 2014-05-11 19:29:00 -1 22:15:00 -24 0 B6
103994 2014-05-11 11:17:00 5 13:55:00 9 0 B6
103995 2014-05-11 07:36:00 -10 09:24:00 -18 0 B6
103996 2014-05-11 13:40:00 0 16:47:00 10 0 B6
tailnum flight origin dest air_time distance duration
103992 N630JB 925 JFK TPA 137 1005 1013
103993 N632JB 225 JFK TPA 137 1005 1929
103994 N635JB 127 EWR MCO 126 937 1117
103995 N637JB 1273 JFK CHS 92 636 0736
103996 N637JB 213 JFK LGB 352 2465 1340
With this data, I want to express dep_delay, arr_delay, air_time and duration as timedeltas, but I keep getting zeroed-out values? I'm using
data['air_time'] = pd.to_timedelta(data['air_time'], errors='coerce')