How to calculate deciles in Python?

Let’s see how to calculate deciles in Python.

deciles python

Calculating deciles in Python

To calculate deciles, we need to import the statistics module.

You can use the quantiles function from the statistics module, specifying n=10, to calculate deciles.

import statistics as s

x = [1, 5, 7, 5, 43, 43, 8, 43, 6, 65, 63, 42, 1, 76, 43, 87, 53, 54]

deciles = s.quantiles(x, n=10)
print("Deciles are: " + str(deciles))

See also  How to calculate quartiles in Python?