def split_trend(history):
    """
    This function splits a time series of gas prices into a trend and a
    residual. The two returned time series sum up to the input time series.

    Keyword arguments:
    history -- the time series to split up

    Return value:
    a tuple of two time series: trend and residual
    """
    #compute trend
    length_week = 7*24
    trend = history.rolling(window=length_week, min_periods=1).mean()
    
    #compute residual
    res = history - trend
    
    return trend, res