Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Lib/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,9 @@ def mode(data):

"""
data = iter(data)
pairs = Counter(data).most_common(1)
try:
return Counter(data).most_common(1)[0][0]
return pairs[0][0]
except IndexError:
raise StatisticsError('no mode for empty data') from None

Expand Down Expand Up @@ -602,6 +603,7 @@ def multimode(data):
# mean=0.300. Only the latter (which corresponds with R6) gives the
# desired cut point with 30% of the population falling below that
# value, making it comparable to a result from an inv_cdf() function.
# The R6 exclusive method is also idempotent.

# For describing population data where the end points are known to
# be included in the data, the R7 inclusive method is a reasonable
Expand Down