jtablesaw/tablesaw

How to customize column names after summarizing is completed

HoasZhang opened this issue · 0 comments

I hope that the results calculated by grouping and aggregating by column names can be customized with column names. I am doing this now, but I hope there can be a better way to implement it.

Table clazz =
            Table.create("Class")
                    .addColumns(
                            StringColumn.create("Class Name", className),
                            IntColumn.create("Class No", classNo));

    Table students =
            Table.create("Student")
                    .addColumns(
                            StringColumn.create("Student Name", studentName),
                            IntColumn.create("class No", studentClassNo),
                            DoubleColumn.create("student Score", studentScore));


    System.out.println(clazz.print());
    System.out.println(students.print());


    Table studentJoiner = students.joinOn("class No").inner( clazz );
    System.out.println(studentJoiner.print());

    Table table1 = studentJoiner.summarize("student Score", max, min)
            .by("class No");

    table1.column( 1 ).setName("Max Score");
    table1.column( 2 ).setName("Min Score");

    System.out.println(table1.print());