# Geometric Mean in Python (Example)

This tutorial illustrates how to compute the geometric mean in Python programming.

The post consists of this information:

Letâ€™s do this!

## Example Data & Add-On Libraries

Iâ€™ll use the data below as a basis for this Python tutorial:

```my_list = [4, 3, 8, 7, 8, 4, 4, 1, 5]    # Create example list
print(my_list)                           # Print example list
# [4, 3, 8, 7, 8, 4, 4, 1, 5]```

The previous output of the Python console shows that our example data is a list object containing nine integers.

## Example: Get Geometric Mean Using gmean() Function of SciPy Library

In this example, Iâ€™ll demonstrate how to calculate the geometric mean of a list in Python.

For this task, we first have to import the gmean function of the SciPy library:

`from scipy.stats import gmean            # Import gmean function of SciPy library`

In the next step, we can apply the gmean function to our example list to get the geometric mean:

```print(gmean(my_list))                    # Apply gmean function
# 4.226198741306655```

As you can see, the geometric mean of the numbers in our list is 4.22.

## Video & Further Resources

Have a look at the following video which I have published on my YouTube channel. In the video, Iâ€™m explaining the Python programming code of this tutorial in the Python programming language:

Furthermore, you might want to read the related articles on this website.

You have learned in this tutorial how to find the geometric mean in Python. Donâ€™t hesitate to let me know in the comments below, in case you have any additional questions.

Subscribe to the Statistics Globe Newsletter