0

If I have [20, 10, 1], I want to get [10, 9, 1] as my output. How can I do this?

([20, 10, 1] = [10+9+1, 9+1, 1])

I want to do this in numpy. Thank you!

Galen BlueTalon
  • 173
  • 4
  • 20
  • 3
    Does this answer your question? [What is the inverse of the numpy cumsum function?](https://stackoverflow.com/questions/38666924/what-is-the-inverse-of-the-numpy-cumsum-function) – user202729 Nov 15 '21 at 23:45
  • 1
    +1 to @user202729's answer, but you just need to flip the indices, so it will be `arr = cum_sum_array[:-1] - cum_sum_array[1:]` – jhso Nov 16 '21 at 00:50

0 Answers0