I have the following numpy arrays (which are actually a pandas column) which represent observations (a position and a value):
df['x'] = np.array([1, 2, 3, 2, 1, 1, 2, 3, 4, 5])
df['y'] = np.array([2, 1, 1, 1, 1, 1, 1, 1, 3, 2])
And instead, I would like to get the following two arrays:
[1 2 3 4 5]
[4 3 2 3 2]
Which is basically grouping all items with the same value in df['x'] and getting the cumulative sum of each value in df['y'], (or in other words getting the cumulative sum of values for each individual position).
Which is the most straightforward way to achieve that in numpy?