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 francismb, rhettinger, steven.daprano
Date 2019-02-11.00:12:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <20190211001203.GR1834@ando.pearwood.info>
In-reply-to <1549219885.57.0.86866159357.issue35892@roundup.psfhosted.org>
Content
Thanks Raymond for the interesting use-case.

The original design of mode() was support only the basic form taught in 
secondary schools, namely a single unique mode for categorical data or 
discrete numerical data.

I think it is time to consider a richer interface to support more uses, 
such as estimating the mode of continuous numerical data, and the 
multi-mode case you bring up.

One reason I've been hesitant is that deciding what is the right 
behaviour is quite hard (or at least it has been for me). I think there 
are a few cases to consider:

- the existing behaviour (which may not be very useful?) which is to
  raise an exception unless the mode is unique; 

- would it be more useful to return an out-of-band value like a NAN 
  or None?

- the multi-mode case where you want some arbitrary(?) mode, possibly
  the left-most (smallest) for numeric data;

- the multi-mode case where you want all the modes.

I like Francis' suggestion to use an enum to select the behavioural, er, 
mode (pun intended). What do you think?
History
Date User Action Args
2019-02-11 00:12:14steven.dapranosetrecipients: + steven.daprano, rhettinger, francismb
2019-02-11 00:12:13steven.dapranolinkissue35892 messages
2019-02-11 00:12:13steven.dapranocreate