def test_aggregate(self):
     aggregates = {
         "asc sum": {
             "column": "asc_idx",
             "operator": "sum"
         },
         "asc q2": {
             "column": "asc_idx",
             "operator": "percentile",
             "options": {
                 "q": 75
             },
         },
         "desc q1": {
             "column": "desc_idx",
             "operator": "percentile",
             "options": {
                 "q": 25
             },
         },
     }
     df = proc.aggregate(df=categories_df,
                         groupby=["constant"],
                         aggregates=aggregates)
     self.assertListEqual(df.columns.tolist(),
                          ["constant", "asc sum", "asc q2", "desc q1"])
     self.assertEqual(series_to_list(df["asc sum"])[0], 5050)
     self.assertEqual(series_to_list(df["asc q2"])[0], 75)
     self.assertEqual(series_to_list(df["desc q1"])[0], 25)
Exemplo n.º 2
0
def test_aggregate():
    aggregates = {
        "asc sum": {
            "column": "asc_idx",
            "operator": "sum"
        },
        "asc q2": {
            "column": "asc_idx",
            "operator": "percentile",
            "options": {
                "q": 75
            },
        },
        "desc q1": {
            "column": "desc_idx",
            "operator": "percentile",
            "options": {
                "q": 25
            },
        },
    }
    df = aggregate(df=categories_df,
                   groupby=["constant"],
                   aggregates=aggregates)
    assert df.columns.tolist() == ["constant", "asc sum", "asc q2", "desc q1"]
    assert series_to_list(df["asc sum"])[0] == 5050
    assert series_to_list(df["asc q2"])[0] == 75
    assert series_to_list(df["desc q1"])[0] == 25