def WA(A,B): c = A*B return c.sum()/A.sum() sample = pd.pivot_table(intime,index=[\'year\'], columns = \'DV\', values = [\'A\',\'B\'],