(self, aggregations: List[pd.Series])
return self.table.from_table(new_domain, table)
Concatenate aggregation series and convert back to Table
Concatenate aggregation series and convert back to Table
Concatenate aggregation series and convert back to Table
def _aggregations_to_table(self, aggregations: List[pd.Series]) -> Table:
        """Concatenate aggregation series and convert back to Table"""
        if aggregations:
            df = pd.concat(aggregations, axis=1)
        else:
            # when no aggregation is computed return a table with gropby columns
            df = self.group_by.first()
            df = df.drop(columns=df.columns)
        gb_attributes = df.index.names
        df = df.reset_index()  # move group by var that are in index to columns
        table = table_from_frame(df)

        # group by variables should be last two columns in metas in the output
        metas = table.domain.metas
        new_metas = [m for m in metas if m.name not in gb_attributes] + [
            table.domain[n] for n in gb_attributes
        ]
        new_domain = Domain(
            [var for var in table.domain.attributes if var.name not in gb_attributes],
            metas=new_metas,
        )
        # keeps input table's type - e.g. output is Corpus if input Corpus
        return self.table.from_table(new_domain, table)
def _aggregations_to_table ( self , aggregations : List [ pd . Series ] ) -> Table : if aggregations : df = pd . concat ( aggregations , axis = 1 ) else : # when no aggregation is computed return a table with gropby columns df = self . group_by . first ( ) df = df . drop ( columns = df . columns ) gb_attributes = df . index . names df = df . reset_index ( ) # move group by var that are in index to columns table = table_from_frame ( df ) # group by variables should be last two columns in metas in the output metas = table . domain . metas new_metas = [ m for m in metas if m . name not in gb_attributes ] + [ table . domain [ n ] for n in gb_attributes ] new_domain = Domain ( [ var for var in table . domain . attributes if var . name not in gb_attributes ] , metas = new_metas , ) # keeps input table's type - e.g. output is Corpus if input Corpus return self . table . from_table ( new_domain , table )