<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def better_ts_function(f):
    '''Decorator which check if timeseries has a better
 implementation of the function.'''
    fname = f.__name__

    def _(ts, *args, **kwargs):
        func = getattr(ts, fname, None)
        if func:
            return func(*args, **kwargs)
        else:
            return f(ts, *args, **kwargs)

    _.__name__ = fname

    return _