statistics.multimode

Full name
statistics.multimode
Library
statistics
Syntax

statistics.multimode(data)

Description

The statistics.multimode function returns a list made up of the most frequent values (the mode) of data. If there is more than one value with the same frequency, they are returned in the order in which they are found in data.

If the structure data is empty, the function returns an empty list.

Parameters
  • data: Structure from which to extract the most frequent values. It can be made up of numbers or values of other types.
Result

The statistics.multimode function returns a list.

Examples

If the mode consists of a single value (as in this example, where the most frequent number is 4), the function returns a list with that value:

statistics.multimode([1, 4, 3, 6, 4, 8])
[4]

However, if there is more than one (the numbers 2 and 4 in this example), the result of the function is a list with these values in the order in which they are found in the structure data:

statistics.multimode([1, 2, 2, 3, 4, 4, 5])
[2, 4]

If applied to a text string, the function returns a list of the most frequent characters in the order in which they are found in the original text:

statistics.multimode("data science")
['a', 'c', 'e']

If the data structure is empty, the function returns an empty list:

statistics.multimode([])
[]
Submitted by admin on Wed, 03/31/2021 - 08:27