Home > Enterprise >  Python 3.9 caused TypeError: int() argument must be a string, a bytes-like object or a number, not &
Python 3.9 caused TypeError: int() argument must be a string, a bytes-like object or a number, not &

Time:10-31

I am converting python 2.7 to python 3.9 with pandas 1.1.5 currently. The below code working in python 2.7 but caused an error when it is in 3.9 (or due to upgrading pandas as well)

agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
headers = {'User-Agent': agent}
query = requests.get('https://query1.finance.yahoo.com/v7/finance/quote?symbols=AALI.JK')
data = query.json()
data = pd.DataFrame(data['quoteResponse']['result'])
data['regularMarketTime']= pd.to_datetime(data['regularMarketTime'],unit='s').dt.strftime("%Y-%m-%d")
data = data[['regularMarketTime','symbol','regularMarketOpen','regularMarketDayHigh','regularMarketDayLow','regularMarketPrice','regularMarketVolume']]
data_append.append(data)

The error as below TypeError: int() argument must be a string, a bytes-like object or a number, not '_NoValueType' in line data = pd.DataFrame(data['quoteResponse']['result']). Why the error occurred and how to fix.

CodePudding user response:

I think data = pd.DataFrame(data.loc['quoteResponse']['result']) could work, let me know if it did

CodePudding user response:

This is problem with python 3.9 with pandas 1.1.5. By running python 3.8 with pandas 1.1.5 fix the issue

  • Related