What would be an elegant and pythonic way to implement cumsum?
Alternatively – if there’a already a built-in way to do it, that would be even better of course…
What would be an elegant and pythonic way to implement cumsum? Alternatively – if
Share
It’s available in Numpy:
Or use
itertools.accumulatesince Python 3.2:If Numpy is not an option, a generator loop would be the most elegant solution I can think of:
Ex.