twopirllc / pandas-ta

Technical Analysis Indicators - Pandas TA is an easy to use Python 3 Pandas Extension with 150+ Indicators
https://twopirllc.github.io/pandas-ta/
MIT License
5.27k stars 1.03k forks source link

AttributeError: 'DataFrame' object has no attribute 'ta' #166

Closed RZeynalov closed 3 years ago

RZeynalov commented 3 years ago

i use pandas-ta-0.2.28b0, the newest one

Describe the bug I d like to start with saying thx to the creator and contributors of the lib. I ve just installed the lib and found that the package doesn t work as an extension to pandas. I ve tried the sample code but always face AttributeError, even print(ta.version) says AttributeError regarding version. Dont know what am i doing wrong..... Tried to find the similiar issue, it looks like i am alone. Help me please.

To Reproduce

import pandas as pd import pandas_ta as ta

Create a DataFrame so 'ta' can be used.

df = pd.DataFrame()

Help about this, 'ta', extension

help(df.ta)

List of all indicators

df.ta.indicators()

Help about the log_return indicator

help(ta.log_return)

twopirllc commented 3 years ago

Hello @RZeynalov,

Interesting. Was there an import error? Do you have a screenshot of the AttributeError (because that is more useful)? What OS are you running? What version of Python? Are you using Anaconda or virtualenv? Are you using a Notebook, ipython, ... ? Does pip list show it installed? If so can you find the installation directory and it's source? Please try to provide as much detail as possible.

Thanks, KJ

RZeynalov commented 3 years ago

windows 10, python 3.7, IDE Pycharm 20.1 Screenshot: image

RZeynalov commented 3 years ago

virtualenv, i am using just python w/out jupiter

Package Version


absl-py 0.11.0 alembic 1.4.3 astor 0.8.1 astunparse 1.6.3 atari-py 0.2.6 attrs 20.3.0 cachetools 4.1.1 certifi 2020.11.8 chardet 3.0.4 cliff 3.5.0 cloudpickle 1.6.0 cmaes 0.7.0 cmd2 1.4.0 colorama 0.4.4 colorlog 4.6.2 cycler 0.10.0 empyrical 0.5.5 future 0.18.2 gast 0.3.3 google-auth 1.23.0 google-auth-oauthlib 0.4.2 google-pasta 0.2.0 grpcio 1.33.2 gym 0.17.3 h5py 2.10.0 idna 2.10 importlib-metadata 3.1.0 joblib 0.17.0 Keras-Applications 1.0.8 Keras-Preprocessing 1.1.2 kiwisolver 1.3.1 lxml 4.6.1 Mako 1.1.3 Markdown 3.3.3 MarkupSafe 1.1.1 matplotlib 3.3.3 MetaTrader5 5.0.33 multitasking 0.0.9 numpy 1.18.5 oauthlib 3.1.0 opencv-python 4.4.0.46 opt-einsum 3.3.0 optuna 2.3.0 packaging 20.4 pandas 1.1.4 pandas-datareader 0.9.0 pandas-ta 0.2.28b0 patsy 0.5.1 pbr 5.5.1 Pillow 8.0.1 pip 20.2.4 prettytable 0.7.2 protobuf 3.14.0 pyasn1 0.4.8 pyasn1-modules 0.2.8 pyglet 1.5.0 pyparsing 2.4.7 pyperclip 1.8.1 pyreadline 2.1 python-dateutil 2.8.1 python-editor 1.0.4 pytz 2020.4 PyYAML 5.3.1 QuantStats 0.0.25 requests 2.25.0 requests-oauthlib 1.3.0 rsa 4.6 scikit-learn 0.23.2 scipy 1.4.1 seaborn 0.11.0 setuptools 50.3.2 six 1.15.0 SQLAlchemy 1.3.20 stable-baselines 2.10.1 statsmodels 0.12.1 stevedore 3.2.2 TA-Lib 0.4.19 tabulate 0.8.7 tensorboard 2.4.0 tensorboard-plugin-wit 1.7.0 tensorflow 2.3.0 tensorflow-estimator 2.3.0 tensorflow-gpu 2.3.0 tensorflow-gpu-estimator 2.3.0 termcolor 1.1.0 threadpoolctl 2.1.0 tqdm 4.53.0 urllib3 1.26.2 wcwidth 0.2.5 Werkzeug 1.0.1 wheel 0.35.1 wrapt 1.12.1 yfinance 0.1.55 zipp 3.4.0

twopirllc commented 3 years ago

Was virtualenv activated prior to running? Rename pandas_ta.py to something else and run it. It is bad practice to name a file of an existing package or module listed in you pip list.

Furthermore, maybe restructure you project directory. Perhaps move that pandas-ta test file that you hopefully renamed in ReinforcementLearning\RashidTest1\anytrader\anytrading_env\envs\ to ReinforcementLearning\RashidTest1\ instead so it's not far from the project root directory.

Based on your pip list, it seems you are building a RL project. If that is the case, check out Python Application Structure/Layouts to get on the right track for building an application.

RZeynalov commented 3 years ago

Ohhh, thank you!!!! Dont know why i called the same name as a package!!! Sorry for disturbing you with such errors, renaming fixed this.
ll work on the structure as well. Thx

twopirllc commented 3 years ago

No worries!

Thanks for using Pandas TA!

inertialfrost commented 2 years ago

Hello, I'm trying this on Google colab, and getting a similar error. Pretty new to Python, anything that I might be missing? pip list shows a huge list but includes pandas-ta 0.3.14b0

Thanks in advance!

twopirllc commented 2 years ago

Hello @inertialfrost,

Honestly, it is hard to troubleshoot without reproducible code, screenshots, etc. Google Colab comes with it's own Issues. Issue 421 shows some colab code that might be useful to get going.

Kind Regards, KJ

dreams-and-thoughts commented 1 year ago

I had a similar issue with a Jupyter notebook in VSCode.

Restarting the kernel (after pip install) fixed it. (of course)

ncimino commented 3 weeks ago

In case someone hits this in the future, this was happening for me in a case where I was using pandas DataFrame in a file but import pandas_ta was not used in the file. Once I added the import pandas_ta then df.ta existed.