Movatterモバイル変換


[0]ホーム

URL:


Python Tutorial

Python statistics.multimode() Function



The Pythonstatistics.multimode function returns the list of most frequently occurring values in the given dataset.

This function will return more than one result if there are multiple modes or an empty list.

Syntax

Following is the basic syntax for thestatistics.multimode() function −

statistics.multimode(data)

Parameters

Here, the data values can be used as any sequence, list or iterator.

Return Value

This function returns the most frequent values from the dataset.

Example 1

In the below example we are calculating the most common values from the dataset usingstatistics.mode() function.

import statisticsx = statistics.multimode('ddddddqqffffggggg')print(x)

Output

The output obtained is as follows −

['d']

Example 2

Here, we are calculating the most frequent values from the dataset usingstatistics.multimode() function.

import statisticsx = statistics.multimode('111113334488888')print(x)

Output

This produces the following result −

['1', '8']

Example 3

Now, we are calculating the multimode from the given dataset usingstatistics.multimode function.

import statisticsx = statistics.multimode('aaaa22fffhhhdddd7777')print(x)

Output

The result is produced as follows −

['a', 'd', '7']
python_modules.htm
Print Page
Advertisements

[8]ページ先頭

©2009-2025 Movatter.jp