I’m sorry if this is obvious (I feels like it should be). I am downloading stock data using a for loop to create a set of dataframes labeled with the ticker name. I wish to not download stocks that return less than x rows in the downloaded data.
I currently have this that is not working?
with open('Tickers/25_tickers.csv') as f:
lines = f.read().splitlines()
for Symbol in lines:
print(Symbol)
vars()[Symbol] = pd.DataFrame()
vars()[Symbol] = yf.download(Symbol, start, end, interval= '1d')
i = vars()[Symbol].shape[0] #try to remove empty and low row df.
if i > 10 == True:
pass
When I use %whos DataFrame I get the list of ‘ticker’ DataFrames and the problem DataFrames still exist.
I’m also not sure if I should do it while downloading or after the dataframes are in.
Any help would be great. Thank you.
>Solution :
with open('Tickers/25_tickers.csv') as f:
lines = f.read().splitlines()
for Symbol in lines:
print(Symbol)
vars()[Symbol] = pd.DataFrame()
vars()[Symbol] = yf.download(Symbol, start, end, interval= '1d')
i = vars()[Symbol].shape[0] #try to remove empty and low row df.
if i < 10:
del vars()[Symbol]