MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / multimode

Function multimode

tools/python-3.11.9-amd64/Lib/statistics.py:716–733  ·  view source on GitHub ↗

Return a list of the most frequently occurring values. Will return more than one result if there are multiple modes or an empty list if *data* is empty. >>> multimode('aabbbbbbbbcc') ['b'] >>> multimode('aabbbbccddddeeffffgg') ['b', 'd', 'f'] >>> multimode('')

(data)

Source from the content-addressed store, hash-verified

714
715
716def multimode(data):
717 """Return a list of the most frequently occurring values.
718
719 Will return more than one result if there are multiple modes
720 or an empty list if *data* is empty.
721
722 >>> multimode('aabbbbbbbbcc')
723 ['b']
724 >>> multimode('aabbbbccddddeeffffgg')
725 ['b', 'd', 'f']
726 >>> multimode('')
727 []
728 """
729 counts = Counter(iter(data))
730 if not counts:
731 return []
732 maxcount = max(counts.values())
733 return [value for value, count in counts.items() if count == maxcount]
734
735
736# Notes on methods for computing quantiles

Callers

nothing calls this directly

Calls 4

CounterClass · 0.90
maxFunction · 0.85
valuesMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected