code: def format_timedelta(t, timedelta_format=None):
      
      timedelta_str = str(pd.Timedelta(t))
      try:
          days_str, time_str = timedelta_str.split(' days ')
      except ValueError:
          # catch NaT and others that don't split nicely
          return timedelta_str
      else:
          if timedelta_format == 'date':
              return days_str + ' days'
          elif timedelta_format == 'time':
              return time_str
          else:
              return timedelta_str
docs: Cast given object to a Timestamp and return a nicely formatted string