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

Function mode

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

Return the most common data point from discrete or nominal data. ``mode`` assumes discrete data, and returns a single value. This is the standard treatment of the mode as commonly taught in schools: >>> mode([1, 1, 2, 3, 3, 3, 3, 4]) 3 This also works with nomi

(data)

Source from the content-addressed store, hash-verified

684
685
686def mode(data):
687 """Return the most common data point from discrete or nominal data.
688
689 ``mode`` assumes discrete data, and returns a single value. This is the
690 standard treatment of the mode as commonly taught in schools:
691
692 >>> mode([1, 1, 2, 3, 3, 3, 3, 4])
693 3
694
695 This also works with nominal (non-numeric) data:
696
697 >>> mode(["red", "blue", "blue", "red", "green", "red", "red"])
698 'red'
699
700 If there are multiple modes with same frequency, return the first one
701 encountered:
702
703 >>> mode(['red', 'red', 'green', 'blue', 'blue'])
704 'red'
705
706 If *data* is empty, ``mode``, raises StatisticsError.
707
708 """
709 pairs = Counter(iter(data)).most_common(1)
710 try:
711 return pairs[0][0]
712 except IndexError:
713 raise StatisticsError('no mode for empty data') from None
714
715
716def multimode(data):

Callers 15

mainFunction · 0.85
setupFunction · 0.85
clock.pyFile · 0.85
cxxabi_tweaks.hFile · 0.85
cxxabi_tweaks.hFile · 0.85
cxxabi_tweaks.hFile · 0.85
cxxabi_tweaks.hFile · 0.85
cxxabi_tweaks.hFile · 0.85
cxxabi_tweaks.hFile · 0.85
cxxabi_tweaks.hFile · 0.85
cxxabi_tweaks.hFile · 0.85

Calls 3

CounterClass · 0.90
StatisticsErrorClass · 0.85
most_commonMethod · 0.80

Tested by

no test coverage detected