Reputation: 169
i have a function that is supposed to chain link a list of daily returns in a dataframe, but when i pass the column, the function is returning a series, rather than a float
def my_aggfunc(x):
y = np.exp(np.log1p(x).cumsum())
return y
if however i change the second line to be
np.sum(x)
this returns a float
Any ideas pls?
Upvotes: 1
Views: 209
Reputation: 2894
From the np.exp
docs:
Calculate the exponential of all elements in the input array.
Returns: out : ndarray Output array, element-wise exponential of x.
So y
is an array.
Upvotes: 0
Reputation: 294318
np.log1p(x)
is an array.
np.log1p(x).cumsum()
is another array of the same size.
np.exp(np.log1p(x).cumsum())
is yet another array.
I'm assuming you didn't want cumsum
you wanted sum
np.exp(np.log1p(x).sum())
Upvotes: 1