Nov-24-2018, 09:41 AM
(This post was last modified: Nov-24-2018, 09:49 AM by ayaz786amd.)
Hi
The code is:
And the error i am getting is
Solved
i use [] instead () here .shift[-forecast_out]
The code is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
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] df.dropna(inplace = True ) print (df.head()) |
Error:Traceback (most recent call last):
File "C:/Program Files/PycharmProjects/code examples/code practice.py", line 28, in <module>
df['label'] = df[forecast_col].shift[-forecast_out]
TypeError: 'method' object is not subscriptable
Solved
i use [] instead () here .shift[-forecast_out]