Bottom Page

Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 TypeError: 'method' object is not subscriptable

The code is:
import pandas as pd
import quandl
import math

df = quandl.get('FINRA/FORF_TLLTD')

df['PCT']= df['ShortVolume']/df['TotalVolume']*100
df = df[['ShortVolume','TotalVolume', 'PCT']]
forecast_col = 'ShortVolume'
df.fillna(-99999, inplace= True)
forecast_out = int(math.ceil(0.01*len(df)))
df['label'] = df[forecast_col].shift[-forecast_out]
And the error i am getting is
Traceback (most recent call last): File "C:/Program Files/PycharmProjects/code examples/code", line 28, in <module> df['label'] = df[forecast_col].shift[-forecast_out] TypeError: 'method' object is not subscriptable


i use [] instead () here .shift[-forecast_out]
Hi, thanks for sharing the solution you found!

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  NoneType' object is not subscriptable shane1236 8 1,630 Sep-12-2019, 07:45 PM
Last Post: shane1236
  TypeError: 'Series' object cannot be interpreted as an integer evelynow 2 4,251 Sep-11-2019, 02:43 PM
Last Post: timmahoney
  TypeError: expected string or bytes-like object twinpiques 1 19,183 May-06-2019, 08:29 PM
Last Post: Yoriz

Forum Jump:

Users browsing this thread: 1 Guest(s)