{"id":25461,"date":"2021-11-16T08:39:29","date_gmt":"2021-11-16T03:09:29","guid":{"rendered":"https:\/\/python-programs.com\/?p=25461"},"modified":"2021-11-16T08:39:29","modified_gmt":"2021-11-16T03:09:29","slug":"python-statistics-mode-method-with-examples","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-statistics-mode-method-with-examples\/","title":{"rendered":"Python statistics.mode() Method with Examples"},"content":{"rendered":"

statistics.mode() Method in Python:<\/strong><\/p>\n

Statistics.mode() computes the mode (central tendency) of a numeric or nominal data set.<\/p>\n

The mode of a set of data values is the most frequently occurring value. It is the most likely value at which the data will be sampled. A mode of a continuous probability distribution is frequently defined as any value x at which its probability density function has a local maximum value, implying that any peak is a mode.<\/p>\n

Syntax:<\/strong><\/p>\n

statistics.mode(data)<\/pre>\n

Parameters<\/strong><\/p>\n

data:<\/strong> This is Required. It is the data values that will be used (it can be any sequence, list, or iterator).<\/p>\n

Note:<\/strong> It is to be noted that if the data is empty, it returns a StatisticsError.<\/p>\n

Return Value:<\/strong><\/p>\n

Returns a float or nominal value that represents the given data’s mode.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given list = ['hello', 'this', 'is', 'btechgeeks', 'hello']<\/pre>\n

Output:<\/strong><\/p>\n

The mode of the given list items ['hello', 'this', 'is', 'btechgeeks', 'hello'] =  hello<\/pre>\n

Explanation:<\/strong><\/p>\n

Here 'hello' occurs most frequently. Hence the mode is 'hello'.<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given list = [3, 4, 2, 5, 6, 3, 3, 1, 3]<\/pre>\n

Output:<\/strong><\/p>\n

The mode of the given list items [3, 4, 2, 5, 6, 3, 3, 1, 3] = 3<\/pre>\n

statistics.mode() Method with Examples in Python<\/span><\/p>\n