def timedelta_to_string(timedelta):
    """
    Utility that converts a pandas.Timedelta to a string representation
    compatible with pandas.Timedelta constructor format

    Parameters
    ----------
    timedelta: pd.Timedelta

    Returns
    -------
    string
        string representation of 'timedelta'
    """
    c = timedelta.components
    format = ''
    if c.days != 0:
        format += '%dD' % c.days
    if c.hours > 0:
        format += '%dh' % c.hours
    if c.minutes > 0:
        format += '%dm' % c.minutes
    if c.seconds > 0:
        format += '%ds' % c.seconds
    if c.milliseconds > 0:
        format += '%dms' % c.milliseconds
    if c.microseconds > 0:
        format += '%dus' % c.microseconds
    if c.nanoseconds > 0:
        format += '%dns' % c.nanoseconds
    return format
def timedelta_to_string ( timedelta ) : c = timedelta . components format = '' if c . days != 0 : format += '%dD' % c . days if c . hours > 0 : format += '%dh' % c . hours if c . minutes > 0 : format += '%dm' % c . minutes if c . seconds > 0 : format += '%ds' % c . seconds if c . milliseconds > 0 : format += '%dms' % c . milliseconds if c . microseconds > 0 : format += '%dus' % c . microseconds if c . nanoseconds > 0 : format += '%dns' % c . nanoseconds return format
Utility that converts a pandas.Timedelta to a string representation
    compatible with pandas.Timedelta constructor format

    Parameters
    ----------
    timedelta: pd.Timedelta

    Returns
    -------
    string
        string representation of 'timedelta'