Thesinus
Thesinus

Reputation: 133

"TypeError: list indices must be integers or slices, not str" in regression analysis

I recently started coding a little bit in Python. Given following data: enter image description here

I just want to make a simple calculation with following code: enter image description here Why do I get the error message when I only have integers and not defined strings? I hope you can help me.

import pandas as pd
import quandl
df= quandl.get("FINRA/FORF_SYNVP", authtoken="sF7es4t9ozY6QjvZyL9M")
df=[['ShortVolume','TotalVolume']]
df['change_PCT']=(df['TotalVolume']-df['ShortVolume'])/df['ShortVolume']*100
df=df[['change_PCT','ShortVolume']]
print(df.head())

Edit: I've tried to type in the code using ´enter the code´ or the Ctrl+K combination but I always receive a error message...

Upvotes: 2

Views: 75

Answers (1)

kederrac
kederrac

Reputation: 17322

you are assigning in the 5th line for df variable a list, the error is legitim, just delete the 5th line

Upvotes: 1

Related Questions