Hi community,
I’m troubleshooting an odd problem where I get a KeyError only with streamlit. Here is the very simple MWE.
Streamlit: 1.34.0
yfinance: 0.2.38
For instance, in my Jupyter notebook, this works:
import yfinance as yf
import pandas as pd
print('getting aapl')
aapl = yf.Ticker('AAPL')
print(aapl.info)
print(aapl.earnings_dates)
print('getting msft')
msft = yf.Ticker('MSFT')
print('ticker gotten msft')
print(msft.info)
print(msft.earnings_dates)
print('finished getting msft')
And here’s the Streamlit version, which fails on ‘MSFT’
import streamlit as st
import pandas as pd
import yfinance as yf
st.write('getting aapl')
aapl = yf.Ticker('AAPL')
st.write(aapl.info)
st.write(aapl.earnings_dates)
st.write('finished getting aapl')
st.write('getting msft')
msft = yf.Ticker('MSFT')
print('ticker gotten msft')
st.write(msft.info)
print('info gotten msft')
st.write(msft.earnings_dates)
st.write('finished getting msft')
I get a KeyError: 'Earnings Date'
. This also happens with ADBE
, but not other tickers I’ve tried.
I can’t tell if this is a streamlit problem or a yfinance problem. I’m posting to the streamlit forum, because I can successfully load the earnings_dates
as Pandas dataframes in Jupyter, so they do not seem malformed.
Any ideas? Curious to see if anyone can reproduce!