before_data = [[100,50,250,300], [101,20,150,150], [101,30,200,150], [102,80,100,200], [102,20,150,200]]
hashed_data = before_data.group_by { |row| row[0] }

#=> {100=>[[100, 50, 250, 300]], 101=>[[101, 20, 150, 150], [101, 30, 200, 150]], 102=>[[102, 80, 100, 200], [102, 20, 150, 200]]}

# 配列の蓄積器に、結果を入れながら、処理を繰り返す
result = hashed_data.each_with_object([]) do | (key, rows), ary |
if rows.length >= 2
puts "rows"
p rows

# 配列の蓄積器に、結果を入れながら、処理を繰り返す
r = rows.each_with_object([]) do | row, ary2 |
if ary2.length == 0
ary2.push *row # 展開
ary2[2] = row[1] * row[2]
else
ary2[1] += row[1]
ary2[2] = ary2[2] + row[1] * row[2]
end
end
r[2] = r[2] / r[1].to_f
ary.push r
else
ary.push rows.flatten
end
end
p result

Ruby で作った。結果
[[100, 50, 250, 300], [101, 50, 180.0, 150], [102, 100, 110.0, 200]]