<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def resample(df, rule, time_index, groupby=None, aggregation='mean'):
 """pd.DataFrame.resample adapter. Call the `df.resample` method on the given time_index and afterwards call the indicated aggregation. Optionally group the dataframe by the indicated columns before performing the resampling. If groupby option is used, the result is a multi-index datagrame. Args: df (pandas.DataFrame):
 DataFrame to resample. rule (str):
 The offset string or object representing target conversion. groupby (list):
 Optional list of columns to group by. time_index (str):
 Name of the column to use as the time index. aggregation (str):
 Name of the aggregation function to use. Returns: pandas.Dataframe: resampled dataframe """

    if groupby:
        df = df.groupby(groupby)

    df = df.resample(rule, on=time_index)
    df = getattr(df, aggregation)()
    for column in groupby:
        del df[column]

    return df