Exemple #1
0
def _coerce_scalar_to_timedelta_type(r, unit="ns", box=True, errors="raise"):
    """ convert strings to timedelta; coerce to Timedelta (if box), else np.timedelta64"""

    result = tslib.convert_to_timedelta(r, unit, errors)
    if box:
        result = tslib.Timedelta(result)

    return result
def _coerce_scalar_to_timedelta_type(r, unit='ns', box=True, errors='raise'):
    """ convert strings to timedelta; coerce to Timedelta (if box), else np.timedelta64"""

    result = tslib.convert_to_timedelta(r,unit,errors)
    if box:
        result = tslib.Timedelta(result)

    return result
Exemple #3
0
def _coerce_scalar_to_timedelta_type(r, unit='ns'):
    """ convert strings to timedelta; coerce to np.timedelta64"""

    if isinstance(r, compat.string_types):

        # we are already converting to nanoseconds
        converter = _get_string_converter(r, unit=unit)
        r = converter()
        unit = 'ns'

    return tslib.convert_to_timedelta(r, unit)
Exemple #4
0
def _coerce_scalar_to_timedelta_type(r, unit='ns'):
    """ convert strings to timedelta; coerce to np.timedelta64"""

    if isinstance(r, compat.string_types):

        # we are already converting to nanoseconds
        converter = _get_string_converter(r, unit=unit)
        r = converter()
        unit='ns'

    return tslib.convert_to_timedelta(r,unit)
Exemple #5
0
def _coerce_scalar_to_timedelta_type(r, unit='ns', box=True, coerce=False):
    """ convert strings to timedelta; coerce to Timedelta (if box), else np.timedelta64"""

    if isinstance(r, compat.string_types):

        # we are already converting to nanoseconds
        converter = _get_string_converter(r, unit=unit)
        r = converter()
        unit='ns'

    result = tslib.convert_to_timedelta(r,unit,coerce)
    if box:
        result = tslib.Timedelta(result)

    return result
Exemple #6
0
def _coerce_scalar_to_timedelta_type(r, unit='ns', box=True, coerce=False):
    """ convert strings to timedelta; coerce to Timedelta (if box), else np.timedelta64"""

    if isinstance(r, compat.string_types):

        # we are already converting to nanoseconds
        converter = _get_string_converter(r, unit=unit)
        r = converter()
        unit = 'ns'

    result = tslib.convert_to_timedelta(r, unit, coerce)
    if box:
        result = tslib.Timedelta(result)

    return result