my script takes in a 'live' online list of F500 companies, iterates through each ticker, grabs ticker performance over a defined period. what i cannot figure out is how to schema/store into a 2D list, multiple rows of ticker data per symbol. somehow the 2nd iterrows will not function. Thanks in Advance:
import pandas as pd #dataframe extends from pd
import pandas_datareader.data as web #grabs stock data
import datetime as dt #to specify date range for grab
#VARS:
#url to f500 list
data_url = "https://query.data.world/s/vjghzuarkh6dap3dblkxanppyh5jtl"
source = "yahoo"
start = dt.datetime(2019, 2, 13) #datetime type
end = dt.datetime.now()
results = []
#read into memory
df500 = pd.read_csv(data_url)
for index, row in df500.tail().iterrows():
try:
dfdr = web.DataReader(row['SYMBOL'], source, start, end) #returns a dataframe presumably
for index2, row2 in dfdr().iterrows():
# here i want to append to the results list: row['SYMBOL'], row2['Date'], row2['High']
print ("test output ", row2[0]) #not even this works
except Exception as e:
pass
# commit to sqlite3 from list or df
The parentheses after dfdr here are wrong:
dfdr().iterrows()
Should be:
dfdr.iterrows()