Message335182
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? |
|
Date |
User |
Action |
Args |
2019-02-11 00:12:14 | steven.daprano | set | recipients:
+ steven.daprano, rhettinger, francismb |
2019-02-11 00:12:13 | steven.daprano | link | issue35892 messages |
2019-02-11 00:12:13 | steven.daprano | create | |
|