Message298924
Apart from being "cool", what is the purpose of this key argument?
For the example shown, where you extract an item from tuple data:
>>> median_low([(1, 2), (3, 3), (4, 1)], key=lambda elem: elem[0])
(3, 3)
I'm not sure I understand when you would use this, and why you would describe (3,3) as a median (a kind of average) of the given data.
By the way, although it's not (yet?) officially supported, it turns out that this works:
py> median_low([(1, 2), (3, 3), (4, 1)])
(3, 3)
Officially, median requires numeric data. If the median* functions were to support tuples, I would be inclined to return a new tuple with the median of each column, as such:
median_low([(1, 2), (3, 3), (4, 1)])
(3, 2) # median of 1,3,4 and median of 2,3,1
I can think of uses for that, e.g. calculating the "Q" correlation coefficient. What uses do you have for your suggested key argument? |
|
Date |
User |
Action |
Args |
2017-07-24 00:43:59 | steven.daprano | set | recipients:
+ steven.daprano, gerion |
2017-07-24 00:43:59 | steven.daprano | set | messageid: <1500857039.5.0.941078720751.issue30999@psf.upfronthosting.co.za> |
2017-07-24 00:43:59 | steven.daprano | link | issue30999 messages |
2017-07-24 00:43:59 | steven.daprano | create | |
|