parameters: (r, unit='ns', box=True, errors='raise')
return_statement: return result
docstring: Convert string 'r' to a timedelta object.
docstring_summary: Convert string 'r' to a timedelta object.
docstring_tokens: Convert string r to a timedelta object .
function: def _coerce_scalar_to_timedelta_type(r, unit='ns', box=True, errors='raise'):
      """Convert string 'r' to a timedelta object."""
  
      try:
          result = Timedelta(r, unit)
          if not box:
              # explicitly view as timedelta64 for case when result is pd.NaT
              result = result.asm8.view('timedelta64[ns]')
      except ValueError:
          if errors == 'raise':
              raise
          elif errors == 'ignore':
              return r
  
          # coerce
          result = pd.NaT
  
      return result
function_tokens: def _coerce_scalar_to_timedelta_type ( r , unit = 'ns' , box = True , errors = 'raise' ) : try : result = Timedelta ( r , unit ) if not box : # explicitly view as timedelta64 for case when result is pd.NaT result = result . asm8 . view ( 'timedelta64[ns]' ) except ValueError : if errors == 'raise' : raise elif errors == 'ignore' : return r # coerce result = pd . NaT return result