hadoop - Calculating average of each line using apache pig -
i'm writing pig script supposed calculate average of each line. input :
(11, 10) (12, 108) (14, 106) (40, 101) (96, 104) (112, 410) and want calculate average of each row this
average(11,10) average(12,108) average(14,106) average(40,101) ... how can ?
to calculate average, pig has built in function called avg. avg takes bag parameter, need create bag out of values. can done script below.
the script below not mind if more 2 values in 1 row, can change liking.
a = load 'data.txt' (a:int, b:int); b = foreach generate tobag($0..) values; c = foreach b generate avg(values);
Comments
Post a Comment