gpt4 book ai didi

python - 使用 pandas 提取 ASX 数据

转载 作者:太空宇宙 更新时间:2023-11-04 05:03:56 25 4
gpt4 key购买 nike

我正在尝试从雅虎财经提取股票市场数据,以下是链接 https://au.finance.yahoo.com/quote/ABP.AX/history?p=ABP.AX

我的代码如下

import pandas as pd
dfs = pd.read_html('https://au.finance.yahoo.com/quote/ABP.AX/history?p=ABP.AX')
print(dfs)

上面的代码导致如下错误

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')

我该如何解决这个问题?

最佳答案

感谢完成使用。

import fix_yahoo_finance as yf
data = yf.download("SPY", start="2017-01-01", end="2017-04-30")

关于python - 使用 pandas 提取 ASX 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44979299/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com