sshashank124 / crypto-rsi-tracker

Python script to track and report favorable cryptocurrency trades using the Binance API
19 stars 13 forks source link

test.py", line 43, in <module> ups_avg = pd.ewm(ups, span=RSI_N)[-1] AttributeError: module 'pandas' has no attribute 'ewm' #2

Closed ray-bun closed 6 years ago

ray-bun commented 6 years ago
test.py", line 43, in <module>
    ups_avg = pd.ewm(ups, span=RSI_N)[-1]
AttributeError: module 'pandas' has no attribute 'ewm'

Im using the latest pandas version. I have tried pd.ewm and pd.ewma but with no luck

Thanks

ray-bun commented 6 years ago

Any help pls? Thank you

sshashank124 commented 6 years ago

Should be pd.ewma. Please show me the error when you try ewma. Also try the following thread: https://github.com/pandas-dev/pandas/issues/14666

ray-bun commented 6 years ago

Error below: test.py", line 42, in ups_avg = pd.ewma(ups, span=RSI_N)[-1] AttributeError: module 'pandas' has no attribute 'ewma'

Sorry, based on that thread what am I changing?

sshashank124 commented 6 years ago

Hmmm even if ewma doesn't work, ewm should still be available in the latest pandas version as you can see here: https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.ewm.html. Make sure you have pandas installed correctly.

ray-bun commented 6 years ago

I have installed correctly and it is showing in my pip3 list. What version are you using? Could you try it with your latest version? I'm on Pandas 23.4 and can confirm that it doesnt work AttributeError: module 'pandas' has no attribute 'ewm'

ray-bun commented 6 years ago

If i try this ups_avg = pd.DataFrame.ewm(ups, span=RSI_N)[-1] downs_avg = -pd.DataFrame.ewm(downs, span=RSI_N)[-1]

Traceback (most recent call last): File "C:/Users/xx/PycharmProjects/rsi/rsi_1min_candle.py", line 128, in main_run() File "C:/Users/xx/PycharmProjects/rsi/rsi_1min_candle.py", line 120, in main_run if check_rsi(BASE_ASSET) >= 72: File "C:/Users/xx/PycharmProjects/rsi/rsi_1min_candle.py", line 72, in check_rsi ups_avg = pd.DataFrame.ewm(ups, span=RSI_N)[-1] File "C:\Users\xx\PycharmProjects\rsi\venv\lib\site-packages\pandas\core\generic.py", line 8924, in ewm axis = self._get_axis_number(axis) AttributeError: 'numpy.ndarray' object has no attribute '_get_axis_number'

ray-bun commented 6 years ago

if I run it with Pandas 0.18.0 FutureWarning: pd.ewm_mean is deprecated for ndarrays and will be removed in a future version downs_avg = -pd.ewma(downs, span=RSI_N)[-1]

ray-bun commented 6 years ago

still an issue, any help pls?

sshashank124 commented 6 years ago

I wasn't able to figure out the problem. I would suggest updating that line of code to use the new API. You can ask on StackOverflow for how to achieve the same functionality with other library methods

antoinecomp commented 5 years ago

ewm is a Dataframe function now, no more a top one. It changed to pd.Dataframe.ewm(com=None, span=None, halflife=None, alpha=None, min_periods=0, adjust=True, ignore_na=False, axis=0) according to the docs.

gusleig commented 5 years ago

Hi, did you have any solution for this? Im trying to calculate RSI with binance client. thanks

SERE026 commented 1 year ago

df['short_ema'] = df.groupby('code')['price_close'].ewma(span=12).mean().reset_index(drop=True) File "/usr/local/python3/lib/python3.6/site-packages/pandas/core/groupby/groupby.py", line 704, in getattr f"'{type(self).name}' object has no attribute '{attr}'"