Counts of events grouped by date in python?

Posted by Sologoub on Stack Overflow See other posts from Stack Overflow or by Sologoub
Published on 2010-03-28T20:29:54Z Indexed on 2010/03/28 20:33 UTC
Read the original article Hit count: 234

Filed under:
|
|

This is no doubt another noobish question, but I'll ask it anyways:

I have a data set of events with exact datetime in UTC. I'd like to create a line chart showing total number of events by day (date) in the specified date range. Right now I can retrieve the total data set for the needed date range, but then I need to go through it and count up for each date.

The app is running on google app engine and is using python.

What is the best way to create a new data set showing date and corresponding counts (including if there were no events on that date) that I can then use to pass this info to a django template?

Data set for this example looks like this:

class Event(db.Model):
    event_name = db.StringProperty()
    doe = db.DateTimeProperty()
    dlu = db.DateTimeProperty()
    user = db.UserProperty()

Ideally, I want something with date and count for that date.

Thanks and please let me know if something else is needed to answer this question!

© Stack Overflow or respective owner

Related posts about google-app-engine

Related posts about python