def test_dict_sum(self):
     agg = BatchAggregate()
     agg.sum_cols = ['batch']
     agg_dict, col_list = agg.create_aggdict()
     self.assertEqual({'batch': ['sum']}, agg_dict)
     self.assertEqual(['sum_batch'], col_list)
 def test_dict_max(self):
     agg = BatchAggregate()
     agg.max_cols = ['batch']
     agg_dict, col_list = agg.create_aggdict()
     self.assertEqual({'batch': ['max']}, agg_dict)
     self.assertEqual(['max_batch'], col_list)
Exemple #3
0
import pandas as pd
from world.flat import Earth
from BatchAggregate.batch_aggregate import BatchAggregate

if __name__ == '__main__':
    earth = Earth()
    print('hello ' + earth.getWord())
    agg = BatchAggregate()

    #print(agg.create_aggdict(['batch']))

    print(agg.weight_cols)
    agg.weight_cols = ['one']  # setter called
    print(agg.weight_cols)
    lst_wght = agg.weight_cols  # getter called
    print(agg.weight_cols, lst_wght)
    # agg.weight_cols = [1]  # setter called
    print(agg.create_aggdict())
    # del agg.weight_cols  # deleter called
    # print(agg.weight_cols, lst_wght)

    df = pd.DataFrame({
        'one': [1, 3, 5, 5, 3, 3, 3, 1],
        'two': [1, 2, 2, 2, 3, 1, 1, 1]
    })
    agg.df = df
    df2 = agg.weight_catcolumns('two')
    print(df2.dtypes)
    print(df2)
    print(agg.list_subcols())