import os
import yahoo_fin.stock_info as si
tickers = ["aapl","msft","fb"]
for ticker in tickers:
try:
quote = si.get_quote_table(ticker)
price = (quote["Quote Price"])
print (ticker, price)
except:
pass
When running this piece of code I get this error:
FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
Can someone tell me how to adapt the code?
CodePudding user response:
Because you aren't using pandas, this looks like an issue with the yahoo_fin
module. There's an open GitHub issue here about it.
It looks like lines 295, 302, and 336 of stock_info.py is the issue in the source code. I've opened a pull request to fix this. The problematic lines like this:
data = tables[0].append(tables[1])
and my PR changes them to this
data = pd.concat([tables[0], tables[1]])
to this fixes the issue. If you are impatient and can't wait for upstream to merge the PR, then you could apply the patch yourself and build from source.
CodePudding user response:
I have never used yahoo_fin
but based on your code and the warning in question, this appears to be something the developers of that library need to change (by using the concat
method instead of append
). In the meantime you can continue to use it as is and ignore the warning or you could always contribute to their codebase, or fork it and make the change for yourself.
Hope that helps,
—K