Author rhettinger
Recipients Windson Yang, cheryl.sabella, francismb, rhettinger, steven.daprano
Date 2019-02-26.01:58:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
>  If others agree that it is sufficiently easy, we can assign 
> the task to Cheryl.

It's only easy if we clearly specify what we want to occur.  Deciding what the right behavior should be is not a beginner skill.

Proposed spec:
Modify the API statistics.mode to handle multimodal cases so that the first mode encountered is the one returned.  If the input is empty, raise a StatisticsError.

    mode([])   --> StatisticsError
    mode('aabbbcc') --> 'c'
    mode(iter('aabbbcc')) --> 'c'
    mode('eeffddddggaaaa') --> 'a'

    * Discard the internal _counts function.
    * Instead use Counter(data).most_common(1)[0][0]
      because that makes only a single pass over the data

    * Update statistics.rst and include a versionchanged directive

    * In the Whatsnew compatibility section, note this is a behavior change.
      Code that used to raise StatisticsError will now return a useful value.
      Note that the rationale for the change is that the current mode()
      behavior would unexpectedly fail when given multimodal data.

    * We want this for 3.8 so it can't wait very long
Date User Action Args
2019-02-26 01:58:06rhettingersetrecipients: + rhettinger, steven.daprano, francismb, cheryl.sabella, Windson Yang
2019-02-26 01:58:06rhettingersetmessageid: <>
2019-02-26 01:58:06rhettingerlinkissue35892 messages
2019-02-26 01:58:06rhettingercreate