This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients gerion, steven.daprano
Date 2017-07-24.00:43:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1500857039.5.0.941078720751.issue30999@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2017-07-24 00:43:59steven.dapranosetrecipients: + steven.daprano, gerion
2017-07-24 00:43:59steven.dapranosetmessageid: <1500857039.5.0.941078720751.issue30999@psf.upfronthosting.co.za>
2017-07-24 00:43:59steven.dapranolinkissue30999 messages
2017-07-24 00:43:59steven.dapranocreate