Re: Efficient counting of results

2017-10-20 Thread Steven D'Aprano
On Fri, 20 Oct 2017 09:05:15 -0800, Israel Brewster wrote: > On Oct 19, 2017, at 5:18 PM, Steve D'Aprano > wrote: >> What t1 and t2 are, I have no idea. Your code there suggests that they >> are fields in your data records, but the contents of the fields, who >> knows? > > t1 and t2 are *indepen

Re: Efficient counting of results

2017-10-20 Thread MRAB
On 2017-10-20 18:05, Israel Brewster wrote:[snip] In a sense, in that it supports my initial approach. As Stefan Ram pointed out, there is nothing wrong with the solution I have: simply using if statements around the calculated lateness of t1 and t2 to increment the appropriate counters. I was

Re: Efficient counting of results

2017-10-20 Thread Israel Brewster
On Oct 19, 2017, at 5:18 PM, Steve D'Aprano wrote: > What t1 and t2 are, I have no idea. Your code there suggests that they are > fields in your data records, but the contents of the fields, who knows? t1 and t2 are *independent* timestamp fields. My apologies - I made the obviously false assump

Re: Efficient counting of results

2017-10-19 Thread MRAB
On 2017-10-20 03:32, Chris Angelico wrote: On Fri, Oct 20, 2017 at 12:18 PM, Steve D'Aprano wrote: On Fri, 20 Oct 2017 05:28 am, Israel Brewster wrote: So if the date of the first record was today, t1 was on-time, and t2 was 5 minutes late, then I would need to increment ALL of the following (

Re: Efficient counting of results

2017-10-19 Thread Chris Angelico
On Fri, Oct 20, 2017 at 12:18 PM, Steve D'Aprano wrote: > On Fri, 20 Oct 2017 05:28 am, Israel Brewster wrote: >> So if the date of >> the first record was today, t1 was on-time, and t2 was 5 minutes late, then >> I would need to increment ALL of the following (using your data structure >> from ab

Re: Efficient counting of results

2017-10-19 Thread Steve D'Aprano
On Fri, 20 Oct 2017 05:28 am, Israel Brewster wrote: > If it helps, my data would look something like this: > > [ (date, key, t1, t2), > (date, key, t1, t2) > . > . > ] > > Where the date and the key are what is used to determine what "on-time" is > for the record, and thus which "late" bin to

Re: Efficient counting of results

2017-10-19 Thread Thomas Jollans
On 19/10/17 20:04, Israel Brewster wrote: >> then loop through the records, find the schedule for that record (if any, if >> not move on as mentioned earlier), compare t1 and t2 against the schedule, >> and increment the appropriate bin counts using a bunch of if statements. >> Functional, if ug

Re: Efficient counting of results

2017-10-19 Thread Peter Otten
Israel Brewster wrote: > >> On Oct 19, 2017, at 10:02 AM, Stefan Ram wrote: >> >> Israel Brewster writes: >>> t10 = {'daily': 0, 'WTD': 0, 'MTD': 0, 'YTD': 0,} >>> increment the appropriate bin counts using a bunch of if statements. >> >> I can't really completely comprehend your requirement

Re: Efficient counting of results

2017-10-19 Thread Israel Brewster
> On Oct 19, 2017, at 10:02 AM, Stefan Ram wrote: > > Israel Brewster writes: >> t10 = {'daily': 0, 'WTD': 0, 'MTD': 0, 'YTD': 0,} >> increment the appropriate bin counts using a bunch of if statements. > > I can't really completely comprehend your requirements > specification, you might hav

Re: Efficient counting of results

2017-10-19 Thread Israel Brewster
> On Oct 19, 2017, at 9:40 AM, Israel Brewster wrote: > > I am working on developing a report that groups data into a two-dimensional > array based on date and time. More specifically, date is grouped into > categories: > > day, week-to-date, month-to-date, and year-to-date > > Then, for eac

Efficient counting of results

2017-10-19 Thread Israel Brewster
I am working on developing a report that groups data into a two-dimensional array based on date and time. More specifically, date is grouped into categories: day, week-to-date, month-to-date, and year-to-date Then, for each of those categories, I need to get a count of records that fall into t