Groupby() on two individual arrays

I have two arrays with same dimension:

a1 = [1,1,3,4,6,6]
a2 = [1,2,3,4,5,6]

But I want to group both of them with respect to array a1 and get the mean of the array a2 for each group.
My output is coming from array a2, as mentioned below:

result:
1.5
3.0
4.0
5.5

Please suggest an approach to achieve this task.
Thanks!!

https://stackoverflow.com/questions/67174230/groupby-using-two-arrays-in-julia/67174276

1 Like