human
Complete the below
def aggregate_returns(returns, convert_to):

    ''''Aggregates returns by day, week, month, or year.'
    '''
 Give me a the Python program you requested?
assistant
#Here is the Python program you requested.
    def cumulate_returns(x):
        return (np.exp(np.log((1 + x)).cumsum())[(-1)] - 1)
    if (convert_to == 'weekly'):
        return returns.groupby([(lambda x: x.year), (lambda x: x.month), (lambda x: x.isocalendar()[1])]).apply(cumulate_returns)
    elif (convert_to == 'monthly'):
        return returns.groupby([(lambda x: x.year), (lambda x: x.month)]).apply(cumulate_returns)
    elif (convert_to == 'yearly'):
        return returns.groupby([(lambda x: x.year)]).apply(cumulate_returns)
    else:
        ValueError('convert_to    must    be    weekly,    monthly    or    yearly')