Mar-05-2018, 05:25 PM
So I am having this problem with my code. I can't figure out why it is working. I am very new to python and would appreciate some help.
The code is:
The code is:
import pandas as pd import quandl df = quandl.get("WIKI/GOOGL", authtoken="X5A1-ewy2UCfkFVfGKuW") df = [["Adj. Open","Adj. High","Adj. Low","Adj. Close","Adj. Volume",]] df["HL_PCT"] = (df["Adj. High"] - df["Adj. Close"]) / df["Adj. Close"] * 100.0 df["PCT_change"] = (df["Adj. Close"] - df["Adj. Open"]) / df["Adj. Open"] * 100.0 df = df [["Adj. Close","HL_PCT","PCT_change","Adj. Volume"]] print(df.head())And the error I am getting is:
Error: RESTART: C:\Users\elias\Desktop\PythonStuff\PythonProjects\MachineLearning.py
Traceback (most recent call last):
File "C:\Users\elias\Desktop\PythonStuff\PythonProjects\MachineLearning.py", line 7, in <module>
df["HL_PCT"] = (df["Adj. High"] - df["Adj. Close"]) / df["Adj. Close"] * 100.0
TypeError: list indices must be integers or slices, not str
Thx :)