Giter Site home page Giter Site logo

TypeError: unsupported operand type(s) for -: 'str' and 'str' or KeyError: "['3,161.25' '3,147.20' '2,975.20' ... '10,600.25' '10,616.45' '10,619.55'] not in index" about ta HOT 5 CLOSED

bukosabino avatar bukosabino commented on July 21, 2024
TypeError: unsupported operand type(s) for -: 'str' and 'str' or KeyError: "['3,161.25' '3,147.20' '2,975.20' ... '10,600.25' '10,616.45' '10,619.55'] not in index"

from ta.

Comments (5)

bukosabino avatar bukosabino commented on July 21, 2024 1

Hi @emptyopen ,

The function add_all_ta_features waits for strings instead of pd.Series for OHLCV parameters. Please, try doing this:

ta.add_all_ta_features(df, close='close', open='open', high='high', low='low', volume='volume', fillna=True)

I will add some documentation for these wrapper functions.

Best,
Dario

from ta.

bukosabino avatar bukosabino commented on July 21, 2024

Hi @sanjaykumar-e ,

A lot of new features were included in the library. Can you reproduce this error again?

Thank you.

from ta.

emptyopen avatar emptyopen commented on July 21, 2024

Hi I'm getting this error as well.

KeyError: "None of [Float64Index([76.36, 75.88, 76.25, 74.82, 75.51, 76.33, 75.89, 75.11, 75.97,\n 76.56, 76.68, 76.15, 76.12, 77.35, 77.85, 76.91, 75.94, 76.38,\n 76.65, 76.85, 77.55, 77.5, 77.45, 78.31, 78.5, 79.49],\n dtype='float64')] are in the [columns]"

In response to ta.add_all_ta_features.

from ta.

bukosabino avatar bukosabino commented on July 21, 2024

Hi @emptyopen

Can you share more information? The code and the dataset would be great.

Best,
Dario

from ta.

emptyopen avatar emptyopen commented on July 21, 2024

Hi, here's the code:

cursor = self.db['A'].find().sort([('date', pymongo.ASCENDING)])
        df = pd.DataFrame(list(cursor))
        print(df[['date', 'close', 'open', 'high', 'low', 'volume']])
        ta.add_all_ta_features(df, close=df['close'], open=df['open'], high=df['high'], low=df['low'], volume=df['volume'], fillna=True)
        print(df)

results in:

          date  close   open   high    low   volume
0   2019-10-15  75.75  75.80  76.36  75.68   854689
1   2019-10-16  75.27  75.30  75.88  74.96  2401590
2   2019-10-17  74.92  75.69  76.25  74.90  1657180
3   2019-10-18  74.57  74.00  74.82  73.77  2121895
4   2019-10-21  75.48  74.88  75.51  74.69  1739523
5   2019-10-22  74.69  75.68  76.33  74.64  1327981
6   2019-10-23  74.98  75.02  75.89  74.68  1828337
7   2019-10-24  75.00  75.03  75.11  74.46  1582478
8   2019-10-25  75.39  74.70  75.97  74.13   835050
9   2019-10-28  76.15  75.69  76.56  75.69  1143869
10  2019-10-29  76.17  75.05  76.68  74.94  1113263
11  2019-10-30  76.12  76.04  76.15  75.24   914844
12  2019-10-31  75.75  76.00  76.12  75.10   970472
13  2019-11-01  76.97  76.51  77.35  76.32  1106314
14  2019-11-04  76.74  77.68  77.85  76.73  1010174
15  2019-11-05  75.55  76.82  76.91  75.47  2362670
16  2019-11-06  75.79  75.70  75.94  74.94  1355737
17  2019-11-07  75.91  76.34  76.38  75.68   860939
18  2019-11-08  76.64  75.90  76.65  75.65  1231456
19  2019-11-11  76.85  76.25  76.85  76.13  1149169
20  2019-11-12  77.05  77.00  77.55  76.72  1008787
21  2019-11-13  77.16  76.82  77.50  76.56  1104429
22  2019-11-14  76.76  77.21  77.45  76.48  1113519
23  2019-11-15  78.26  76.93  78.31  76.61  1700368
24  2019-11-18  77.94  78.14  78.50  77.50  1641215
25  2019-11-19  79.29  78.17  79.49  77.84  1704766
Traceback (most recent call last):
  File "C:/Users/Takkeezi/PycharmProjects/capitVita/application.py", line 13, in <module>
    calculator.calculate_indicators()
  File "C:\Users\Takkeezi\PycharmProjects\capitVita\DataCalculator\DataCalculator.py", line 48, in calculate_indicators
    ta.add_all_ta_features(df, close=df['close'], open=df['open'], high=df['high'], low=df['low'], volume=df['volume'], fillna=True)
  File "C:\Users\Takkeezi\Anaconda3\lib\site-packages\ta\wrapper.py", line 290, in add_all_ta_features
    df = add_volume_ta(df=df, high=high, low=low, close=close, volume=volume, fillna=fillna, colprefix=colprefix)
  File "C:\Users\Takkeezi\Anaconda3\lib\site-packages\ta\wrapper.py", line 39, in add_volume_ta
    high=df[high], low=df[low], close=df[close], volume=df[volume], fillna=fillna).acc_dist_index()
  File "C:\Users\Takkeezi\Anaconda3\lib\site-packages\pandas\core\frame.py", line 2986, in __getitem__
    indexer = self.loc._convert_to_indexer(key, axis=1, raise_missing=True)
  File "C:\Users\Takkeezi\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 1285, in _convert_to_indexer
    return self._get_listlike_indexer(obj, axis, **kwargs)[1]
  File "C:\Users\Takkeezi\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 1092, in _get_listlike_indexer
    keyarr, indexer, o._get_axis_number(axis), raise_missing=raise_missing
  File "C:\Users\Takkeezi\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 1177, in _validate_read_indexer
    key=key, axis=self.obj._get_axis_name(axis)
KeyError: "None of [Float64Index([76.36, 75.88, 76.25, 74.82, 75.51, 76.33, 75.89, 75.11, 75.97,\n              76.56, 76.68, 76.15, 76.12, 77.35, 77.85, 76.91, 75.94, 76.38,\n              76.65, 76.85, 77.55,  77.5, 77.45, 78.31,  78.5, 79.49],\n             dtype='float64')] are in the [columns]"

from ta.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.