I have big data loaded from a pickle file. The data is a sorted list of tuples containing datetime and int like this
[ (datetime.datetime(2010, 2, 26, 12, 8, 17), 5594813L), (datetime.datetime(2010, 2, 26, 12, 7, 31), 5594810L), (datetime.datetime(2010, 2, 26, 12, 6, 4) , 5594807L), etc ]
I want to get population density based on some time intervals. For example, I want to capture the number of records in 5 minutes / 1 minute / 30 seconds.
What is the best way to do this? I know that I can just iterate over all instances in the list, but I was looking for a better approach (if one exists).
The desired output would be something like this:
2010-01-01 04:10:00 --- 5000 2010-02-04 10:05:00 --- 4000 2010-01-02 13:25:00 --- 3999
python
sberry
source share