The advantage of using numpy is that you can specify an optional axis
argument along which the mean should be calculated:
def geom_mean(arr, axis=None):
return np.exp(np.mean(np.log(arr), axis=axis))
It uses the identity exp(arithmetic_mean(log(values))) = geometric_mean(values)