How to use Statistics module In Python

Like NumPy module, the statistics module also contains statistical functions like mean , median , mode….etc . So let us see an example of a mode using the statistics module.

Example :

Python3




import statistics as st
import numpy as np
 
# create an 1 d array
arr1 = np.array([9, 8, 7, 6, 6, 6, 6, 5, 5, 4,
                 3, 2, 1, 1, 1, 1, 1, 1])
 
# display the mode
print(st.mode(arr1))


Output :

1

How to Calculate the Mode of NumPy Array?

In this article, we will discuss how to calculate the mode of the Numpy Array.

Mode refers to the most repeating element in the array. We can find the mode from the NumPy array by using the following methods.

Similar Reads

Method 1: Using scipy.stats package

Let us see the syntax of the mode() function...

Method 2: Using Statistics module

...

Method 3: Using user-defined Function

...