Extracting ASX data with pandas
I am trying to extract stock market data from yahoo finance by following the link https://au.finance.yahoo.com/quote/ABP.AX/history?p=ABP.AX
My code looks like this
import pandas as pd
dfs = pd.read_html('https://au.finance.yahoo.com/quote/ABP.AX/history?p=ABP.AX')
print(dfs)
The above code results in the following error
Traceback (most recent call last):
File "/home/furqan/Desktop/Data/Fundamental Analysis/get_data/ax_data.py", line 5, in <module>
dfs = pd.read_html('https://au.finance.yahoo.com/quote/ABP.AX/history?p=ABP.AX')
File "/usr/local/lib/python3.5/dist-packages/pandas/io/html.py", line 874, in read_html
parse_dates, tupleize_cols, thousands, attrs, encoding)
File "/usr/local/lib/python3.5/dist-packages/pandas/io/html.py", line 747, in _parse
thousands=thousands))
File "/usr/local/lib/python3.5/dist-packages/pandas/io/html.py", line 628, in _data_to_frame
_expand_elements(body)
File "/usr/local/lib/python3.5/dist-packages/pandas/io/html.py", line 611, in _expand_elements
body[ind] += empty * (lens_max - length)
TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('<U47') dtype('<U47') dtype('<U47')
How can I solve this problem?
+3
source to share
2 answers