Reputation: 141
I have four Series objects nSer1, nSer2, nSer3 and nSer4. How to create nSerGMean which multiplies the series and takes the fourth root of the result.
nSerGMean=(nSer1*nSer2*nSer3*nSer4)^(1/4)
Upvotes: 0
Views: 95
Reputation: 30605
Use mul
and pow
methods i.e:
nSerGMean = (nSer1.mul(nSer2).mul(nSer3).mul(nSer4)).pow(1/4)
Upvotes: 1
Reputation: 484
You can use numpy product along a specific dimension.
import numpy as np
nSerGMean = np.power(np.prod([nSer1,nSer2,nSer3,nSer4], axis = 0),0.25)
Optionally, you can do a log-transformation first to use summation instead.
nSerGMean = np.exp(
np.mean( np.log([nSer1,nSer2,nSer3,nSer4]), axis = 0)
)
Upvotes: 3