Pandas a has a very efficient method to calculate ewm, I looked at the source code but cannot find the actual method used. I am assuming it is cythonised for speed.
Can someone show the actual method to do it so quickly, since the only way I can think of is it to iterate and calc:
value = df.columns.get_loc('value')
ema = df.columns.get_loc('ema')
alpha = 0.01 #example
for i in range(0, len(df) -1):
if(i>0):
df.iat[i, ema] = df.iat[i-1,ema] + alpha*(df.iat[i,value] - df.iat[i-1,ema])
else:
df.iat[i, ema] = df.iat[i,value]