I have a problem on hierarchy.i have data like this.
id performance_rating parent_id level
111 8 null 0
122 3 null 0
123 9 null 0
254 5 111 1
265 8 111 1
298 7 122 1
220 6 123 1
305 5 298 2
395 8 220 2
... ... ... ...
654 4 562 5
the id is person unique identity. performance_rating is his rating out of 10 parent_id is the id of the person who is working above the corresponding id.
I need to find out the average rating of an individual tree(111,122,123).
what I tried is separate data frame according to levels. Then merge it and groupby. But it is quite long.
roll up?