Saturday, February 20
If I Don't Lesnerize, The Feegs Can't Get Me
In SQL* you say
In addition, I've added a
I'm working on two more functions now,
As long as I don't come down with kurtosis...
Update: Kang and jag. Or rather, agg and tab. For aggregate and tabulate.
* Boo, hiss!
** Or indeed
*** Which should come out the same as the average; just one I'm calculating myself and the other I'm pulling out of a stats module.
Comments are disabled.
Post is locked.
In SQL* you say
select sum(sales) from accounts where state="NY"
. In Pita, the way to do this is:results = accounts.aggregate(state='NY')
**
which will calculate for you the count, length, sum, minimum and maximum, as appropriate, for all the fields in the table at once, so the value you need is results.sales.sum
. Since the table scan is typically slower than any calculations you're likely to be doing, this seems a reasonable approach.In addition, I've added a
results = accounts.stats()
which provides all those, plus mean,*** median, mode, standard deviation, and geometric and harmonic means. Aaaaand standard error, coefficient of variation, sample and population variance, skewness and kurtosis. I even sort of know what kurtosis is.I'm working on two more functions now,
group
and break
, though I may need to come up with another name for the latter because break is a Python keyword. This:for result in accounts.group('state', country='US'): ...
would give you the aggregate sales figures for each state in the US, sensibly enough. And this:for result in accounts.break('state', country='US'):
...
would give you the individual sales figures, and then automatically provide totals after the last sales record for each state.As long as I don't come down with kurtosis...
Update: Kang and jag. Or rather, agg and tab. For aggregate and tabulate.
for line in accounts.aggregate('state', country='US'): ...
will give you one summary line for each state, where for line in accounts.tabulate('state', country='US'):
...
would give you both detail and summary lines. I need to put subtotal and total flags on the records for tabulate. Have to watch the keywords, there. And keep my closet doors closed.* Boo, hiss!
** Or indeed
results =
accounts(state='NY').aggregate()Either way should perform the same and produce the same results. I think...*** Which should come out the same as the average; just one I'm calculating myself and the other I'm pulling out of a stats module.
Posted by: Pixy Misa at
03:14 AM
| Comments (2)
| Add Comment
| Trackbacks (Suck)
Post contains 316 words, total size 3 kb.
1
OT: Pixy, I don't know what they did, but I can't load the Jawas now without locking up IE8. (Firefox has no problem with it.)
Posted by: Steven Den Beste at Saturday, February 20 2010 10:56 AM (+rSRq)
2
As I look at it with Firefox, I see that there's a formatting problem with the post titled "NYT: Brooklyn Accent = RAAAACIST!"
That may be related.
Posted by: Steven Den Beste at Saturday, February 20 2010 11:00 AM (+rSRq)
48kb generated in CPU 0.0494, elapsed 0.1349 seconds.
56 queries taking 0.1255 seconds, 348 records returned.
Powered by Minx 1.1.6c-pink.
56 queries taking 0.1255 seconds, 348 records returned.
Powered by Minx 1.1.6c-pink.