<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def weld_groupby_aggregate(grouped_df, weld_types, by_indices, aggregation, result_type=None):
 """Perform aggregation on grouped data. Parameters grouped_df : WeldObject DataFrame which has been grouped through weld_groupby. weld_types : list of WeldType Corresponding to data. by_indices : list of int Indices of which arrays to group by. aggregation : {'+', '*', 'min', 'max', 'mean', 'var', 'std'} What operation to apply to grouped rows. result_type : WeldType, optional Whether the result shall be (casted to) some specific type. Returns ------- (list of WeldType, WeldObject) Tuple of newly ordered Weld types and the WeldObject representation of the computation. """

    obj_id, weld_obj = create_weld_object(grouped_df)

    all_indices = list(range(len(weld_types)))
    column_indices = list(filter(lambda x: x not in by_indices, all_indices))
    by_weld_types = [weld_types[i] for i in by_indices]
    column_weld_types = [weld_types[i] for i in column_indices]
    new_column_weld_types = column_weld_types if result_type is None else [result_type for _ in column_weld_types]

    by_types = struct_of('{e}', by_weld_types)
    column_types = struct_of('{e}', column_weld_types)
    new_column_types = struct_of('{e}', new_column_weld_types)
    grouped_df_types = '{{{}, {}}}'.format(by_types, column_types)
    res = '{{{}}}'.format(', '.join(['e.$0.${}'.format(i) for i in range(len(by_weld_types))] +
                                    ['e.$1.${}'.format(i) for i in range(len(column_weld_types))]))

    weld_template = """map(
    tovec(
        result(
            for(
                {grouped_df},
                dictmerger[{by_types}, {new_column_types}, +],
                |b: dictmerger[{by_types}, {new_column_types}, +], i: i64, e: {{{by_types}, vec[{column_types}]}}|
                    {computation}
            )
        )
    ),
    |e: {{{by_types}, {new_column_types}}}|
        {res}
)"""

    weld_template = weld_template.replace('{computation}',
                                          _assemble_computation(aggregation,
                                                                column_weld_types,
                                                                new_column_weld_types),
                                          1)

    weld_obj.weld_code = weld_template.format(grouped_df=obj_id,
                                              by_types=by_types,
                                              column_types=column_types,
                                              new_column_types=new_column_types,
                                              grouped_df_types=grouped_df_types,
                                              res=res)

    return by_weld_types + new_column_weld_types, weld_obj