I want to find out exponential moving average (12 days) for a dataframe. As given in the pandas documentation 0.19.2, I've used the function DataFrame.ewm to calcuate the exponential moving average. But it results in an error as follows AttributeError: 'DataFrame' object has no attribute 'ewm'. Below is the code I've used to calculate exponential moving average.
avg_gain=pd.gain.ewm(span=12,min_periods=12,adjust=False).mean()
On the other hand, in prior pandas documentation there is function ewma to calculate exponential moving average but this function results in undesired results. Can't figure out the issue?
It seems that you are using an older version of pandas.
import pandas
pandas.__version__
To upgrade, use pip.
sudo pip3 install pandas --upgrade # UNIX
pip install pandas --upgrade # Windows
If you do not have pip installed, you can replace pip with python -m "pip", or pip3 with python3 -m "pip".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With