並びは保持しない (pandasとかじゃない) Pythonでの方法
(別解の初期処理そのまま利用させてもらいました)
from itertools import groupby
import numpy as np
arr = np.random.randint(4, 10, (20, 3))
grpkey = lambda x: [x[0], x[1]]
res = [k +[sum(m[-1]for m in g)]
for k,g in groupby(sorted(arr, key=grpkey), grpkey)]
# 結果の表示
for k,g in groupby(sorted(arr, key=grpkey), grpkey):
print(k, list(g))
# [4, 8] [array([4, 8, 8])]
# [5, 4] [array([5, 4, 4])]
# [5, 5] [array([5, 5, 6])]
# [5, 6] [array([5, 6, 7])]
# [5, 7] [array([5, 7, 8]), array([5, 7, 6]), array([5, 7, 7]), array([5, 7, 6]), array([5, 7, 5])]
# [5, 8] [array([5, 8, 4])]
# [6, 4] [array([6, 4, 6])]
# [6, 9] [array([6, 9, 8])]
# [7, 7] [array([7, 7, 4])]
# [7, 9] [array([7, 9, 6]), array([7, 9, 8])]
# [8, 5] [array([8, 5, 5]), array([8, 5, 8])]
# [8, 9] [array([8, 9, 4]), array([8, 9, 4])]
# [9, 8] [array([9, 8, 4])]
display(res)
# [[4, 8, 8],
# [5, 4, 4],
# [5, 5, 6],
# [5, 6, 7],
# [5, 7, 32],
# [5, 8, 4],
# [6, 4, 6],
# [6, 9, 8],
# [7, 7, 4],
# [7, 9, 14],
# [8, 5, 13],
# [8, 9, 8],
# [9, 8, 4]]