to_timedelta

typhon.utils.to_timedelta(obj, numbers_as=None)[source]

Convert an object to a python datetime object.

Parameters:
  • obj – Can be a string with time information, a number, a numpy.timedelta64 or a pandas.Timedelta object.

  • numbers_as – A string that indicates how numbers should be interpreted. Allowed values are weeks, days, hours, minutes, seconds, milliseconds and microseconds.

Returns:

A python datetime object.

Examples:

# A timedelta object with 200 seconds
t = to_timedelta("200 seconds")

# A timedelta object with 24 days
t = to_timedelta(24, numbers_as="days")