#NEWLINE# def test_by_groupby_deep( ) : #NEWLINE# #INDENT# data = [ ( 1 , 2 , 'Alice' ) , ( 1 , 3 , 'Bob' ) , ( 2 , 4 , 'Alice' ) , ( 2 , 4 , '' ) ] #NEWLINE# schema = '{x: int, y: int, name: string}' #NEWLINE# t = symbol ( 't' , ( datashape . var * schema ) ) #NEWLINE# t2 = t [ ( t [ 'name' ] != '' ) ] #NEWLINE# t3 = merge ( t2 . x , t2 . name ) #NEWLINE# expr = by ( schema . name , avg = t3 . x . mean ( ) ) #NEWLINE# result = set ( compute ( expr , data ) ) #NEWLINE# assert ( result == set ( [ ( 'Alice' , 1.5 ) , ( 'Bob' , 1.0 ) ] ) )