2

For the first time, I'm unable to use the .shift() method on a column of the DataFrame I'm working with, giving me a DataFrame' object is not callable error.

sdf = quandl.get("AAII/AAII_SENTIMENT", authtoken="mytoken")
sdf = pd.DataFrame(data = sdf)
sdf = sdf.infer_objects()
sdf.index = pd.to_datetime(sdf.index, dayfirst=True)
sdf = sdf.iloc[9:,]
sdf['sp500_2w_future_close'] = sdf(['S&P 500 Weekly Close']).shift(-2)

I was expecting to get a new column displaying S&P 500 Weekly Close two rows down and instead got this weird error. He, p please!

Nazim Kerimbekov
  • 4,712
  • 8
  • 34
  • 58
Kaibo
  • 21
  • 1
  • 3
    `sdf` is a DataFrame, and you do `sdf(['S&P 500 Weekly Close'])` which basically means you are trying to "call" (as in a function, for example `f(x)`) the `sdf`. Instead, you probably mean `sdf['S&P 500 Weekly Close']` – rafaelc Apr 06 '19 at 23:02
  • 1
    You're awesome, thank you. – Kaibo Apr 07 '19 at 03:59

0 Answers0