def __call__(self, df):
    pdf = self.grouped_data.df._yield_pdf()
    agg_fn_cols = []
    agg_variations = set()
    const_cols = []
    resolved_cols = []
    for col in self.agg_cols:
        col = resolve_alias(col)
        resolved_cols.append(col)
        if isinstance(col, _Function):
            agg_fn_cols.append(col)
            if isinstance(col.spec, SimpleAggregationFunctionSpec):
                agg_variations.add(col.spec.fn)
            else:
                raise TypeError()
        elif isinstance(col, _Literal):
            const_cols.append(col)
        else:
            raise TypeError(col.__class__)
    if (len(self.grouped_data.cols) > 0):
        pg = pdf.groupby(by=[pdf.iloc[:, col.index] for col in self.grouped_data.cols])
        agg_result = pg.aggregate(list(agg_variations))
        agg_result = pandas.concat([agg_result.index.to_frame(), agg_result], axis=1)
        agg_result_index = agg_result.index.to_frame()
        series_set = [agg_result_index[col].rename(i) for (i, col) in enumerate(agg_result_index.columns)]
        for col in resolved_cols:
            if isinstance(col, _Function):
                if isinstance(col.spec, SimpleAggregationFunctionSpec):
                    series = agg_result[(col.operands[0].index, col.spec.fn)].rename(len(series_set))
                else:
                    assert False
            elif isinstance(col, _Literal):
                series = pandas.Series([col.value], name=len(series_set))
            else:
                assert False
            series_set.append(series)
    else:
        agg_result = pdf.aggregate(list(agg_variations))
        series_set = []
        for col in self.agg_cols:
            if isinstance(col, _Function):
                if isinstance(col.spec, SimpleAggregationFunctionSpec):
                    series = pandas.Series([agg_result[col.operands[0].index][col.spec.fn]], name=len(series_set))
                else:
                    assert False
            elif isinstance(col, _Literal):
                series = pandas.Series([col.value], name=len(series_set))
            else:
                assert False
            series_set.append(series)
    return pandas.concat(series_set, axis=1)
def __call__(self, df):
    pdf = self.grouped_data.df._yield_pdf()
    agg_fn_cols = []
    agg_variations = set()
    const_cols = []
    resolved_cols = []
    for col in self.agg_cols:
        col = resolve_alias(col)
        resolved_cols.append(col)
        if isinstance(col, _Function):
            agg_fn_cols.append(col)
            if isinstance(col.spec, SimpleAggregationFunctionSpec):
                agg_variations.add(col.spec.fn)
            else:
                raise TypeError()
        elif isinstance(col, _Literal):
            const_cols.append(col)
        else:
            raise TypeError(col.__class__)
    if (len(self.grouped_data.cols) > 0):
        pg = pdf.groupby(by=[pdf.iloc[:, col.index] for col in self.grouped_data.cols])
        agg_result = pg.aggregate(list(agg_variations))
        agg_result = pandas.concat([agg_result.index.to_frame(), agg_result], axis=1)
        agg_result_index = agg_result.index.to_frame()
        series_set = [agg_result_index[col].rename(i) for (i, col) in enumerate(agg_result_index.columns)]
        for col in resolved_cols:
            if isinstance(col, _Function):
                if isinstance(col.spec, SimpleAggregationFunctionSpec):
                    series = agg_result[(col.operands[0].index, col.spec.fn)].rename(len(series_set))
                else:
                    assert False
            elif isinstance(col, _Literal):
                series = pandas.Series([col.value], name=len(series_set))
            else:
                assert False
            series_set.append(series)
    else:
        agg_result = pdf.aggregate(list(agg_variations))
        series_set = []
        for col in self.agg_cols:
            if isinstance(col, _Function):
                if isinstance(col.spec, SimpleAggregationFunctionSpec):
                    series = pandas.Series([agg_result[col.operands[0].index][col.spec.fn]], name=len(series_set))
                else:
                    assert False
            elif isinstance(col, _Literal):
                series = pandas.Series([col.value], name=len(series_set))
            else:
                assert False
            series_set.append(series)
    return pandas.concat(series_set, axis=1)