[issue30999] statistics module: add "key" keyword argument to median, mode, ...

2019-01-18 Thread Rémi Lapeyre
Rémi Lapeyre added the comment: I suggest we closed this issue in favor of #35775 to discuss adding a selection function and the attached PR. -- nosy: +remi.lapeyre ___ Python tracker

[issue30999] statistics module: add "key" keyword argument to median, mode, ...

2018-11-04 Thread Raymond Hettinger
Raymond Hettinger added the comment: This issue (as originally proposed) should be closed. A key function for median() and mode() likely isn't a good idea. Those two functions should be kept parallel with mean() as returning simple descriptive statistics. Work towards a select()

[issue30999] statistics module: add "key" keyword argument to median, mode, ...

2018-10-17 Thread Michal Nowikowski
Michal Nowikowski added the comment: What is the progress of this issue? I'm also interested in this feature. I expected that these functions will behave as built-in min and max. They have key argument, see here: https://docs.python.org/3/library/functions.html#max -- nosy: +godfryd

[issue30999] statistics module: add "key" keyword argument to median, mode, ...

2017-07-31 Thread Raymond Hettinger
Raymond Hettinger added the comment: > I don't think it makes sense to add key arguments to mode, mean, > variance etc. I'm having trouble thinking of what that would > even mean I concur. This proposal bends the concept of a key-function to where it is no longer obvious what it does. > I've

[issue30999] statistics module: add "key" keyword argument to median, mode, ...

2017-07-24 Thread Steven D'Aprano
Steven D'Aprano added the comment: I've given this some more thought, and I think that a "key" argument would make sense for a general selection function. The general selection problem is: given a set of items A, and a number k between 1 and the number of items, return the k-th item. In

[issue30999] statistics module: add "key" keyword argument to median, mode, ...

2017-07-24 Thread gerion
gerion added the comment: The position might be useful, if you have a second list with some side data stored in it, and not a list of tuples :). I had the idea to file a bug, when I had a list of coordinates and wanted to use the point with the median of the x-coordinates as "representation"

[issue30999] statistics module: add "key" keyword argument to median, mode, ...

2017-07-24 Thread Steven D'Aprano
Steven D'Aprano added the comment: Thanks for explaining your use-case. Although the median_* functions don't perform arithmetic on their data, they are still conceptually mathematical functions that operate on numbers and I'm reluctant to support arbitrary objects with a key function

[issue30999] statistics module: add "key" keyword argument to median, mode, ...

2017-07-24 Thread Mark Dickinson
Changes by Mark Dickinson : -- nosy: +mark.dickinson ___ Python tracker ___ ___

[issue30999] statistics module: add "key" keyword argument to median, mode, ...

2017-07-23 Thread gerion
gerion added the comment: My use case is some side data somehow connected to the statistical relevant data. (I think, this is more less a similar use case as with the min and max function.) A few examples: The datastructure is a list of tuples: (score, [list of people that have this score])

[issue30999] statistics module: add "key" keyword argument to median, mode, ...

2017-07-23 Thread Steven D'Aprano
Steven D'Aprano added the comment: 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,

[issue30999] statistics module: add "key" keyword argument to median, mode, ...

2017-07-23 Thread gerion
New submission from gerion: With Python 3.4 the statistics module was added. It would be cool, if the functions: median_low() median_high() mode() would have a "key" keyword argument, just like in max() and min(): ``` >>> median_low([(1, 2), (3, 3), (4, 1)], key=lambda elem: elem[0]) (3, 3) ```