def convert_timedelta(obj):
 if ((not PY2) and isinstance(obj, (bytes, bytearray))):
  obj = obj.decode('ascii')
 m = TIMEDELTA_RE.match(obj)
 if (not m):
  return None
 try:
  groups = list(m.groups())
  groups[(-1)] = _convert_second_fraction(groups[(-1)])
  negate = ((-1) if groups[0] else 1)
  (hours, minutes, seconds, microseconds) = groups[1:]
  tdelta = (datetime.timedelta(hours=int(hours), minutes=int(minutes), seconds=int(seconds), microseconds=int(microseconds)) * negate)
  return tdelta
 except ValueError:
  return None

def convert_timedelta ( obj ) : if ( ( not PY2 ) and isinstance ( obj , ( bytes , bytearray ) ) ) : obj = obj . decode ( 'ascii' ) m = TIMEDELTA_RE . match ( obj ) if ( not m ) : return None try : groups = list ( m . groups ( ) ) groups [ ( - 1 ) ] = _convert_second_fraction ( groups [ ( - 1 ) ] ) negate = ( ( - 1 ) if groups [ 0 ] else 1 ) ( hours , minutes , seconds , microseconds ) = groups [ 1 : ] tdelta = ( datetime . timedelta ( hours = int ( hours ) , minutes = int ( minutes ) , seconds = int ( seconds ) , microseconds = int ( microseconds ) ) * negate ) return tdelta except ValueError : return None
returns a time column as a timedelta object: .