spencermeyer

Cumulative Sum by year?

Discussion created by spencermeyer on Jan 9, 2013
Latest reply on Jul 5, 2016 by bixb0012
Hello,

I have a table that is something like:

Object    Year    Acres
1            1980   5
2            1979   3
3            1978   2
4            1980   8
5            1979   2
6            1976   6

I would like to use python to create a cumulative sum so that I end up with a table that looks like:
1976       6
1978       2
1979       5
1980       13

I'm going to be graphing this using matplotlib, showing trends in acres over time.

I'm a beginner with python. So far I've tried to use FeatureClasstoNumPyArray and numpy's cumsum, but I can't get the array structured correctly to sum by year. I think part of my problem is that I don't really understand how an attribute table gets converted to an array.

If numpy is the wrong approach, pleases let me know. My requirements are that I can graph cumulative acres over time from a dataset that has polygons of various sizes occuring in specific years. If it matters for processing time, this dataset has about 140,000 records. Also, if you have any suggestions for python graphing modules or sample code that will do with kind of thing well, I'd like to know about them.

thanks!

Outcomes