statistics.multimode(data)
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.
- data: Structure from which to extract the most frequent values. It can be made up of numbers or values of other types.
The statistics.multimode function returns a list.
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:
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:
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:
If the data structure is empty, the function returns an empty list: