Python、Pandas、雅虎财经 API

Python, Pandas, Yahoo Finance API

无法获取 Pandas 数据 reader 从 Yahoo API 检索报价。最新的答案似乎是:

"pip install --upgrade pandas pip install --upgrade pandas-datareader

但是,目前我将使用 Google Collab 及其 Python 平台,有人知道如何更新这里的 pandas 吗?还是 API 真的停产了?

在 Colab 中,您需要在 pip

之前放置一个 !

好的,我找到答案了!正如 PythonPerfection 上面所说 ^ 代码确实需要在 pip 之前添加 !

但是,Google Colab 在 1.3.5 之前只有 pandas 更新:

ERROR: Could not find a version that satisfies the requirement pandas==1.4.1 (from versions: 0.1, 0.2, 0.3.0, 0.4.0, 0.4.1, 0.4.2, 0.4.3, 0.5.0, 0.6.0, 0.6.1, 0.7.0, 0.7.1, 0.7.2, 0.7.3, 0.8.0, 0.8.1, 0.9.0, 0.9.1, 0.10.0, 0.10.1, 0.11.0, 0.12.0, 0.13.0, 0.13.1, 0.14.0, 0.14.1, 0.15.0, 0.15.1, 0.15.2, 0.16.0, 0.16.1, 0.16.2, 0.17.0, 0.17.1, 0.18.0, 0.18.1, 0.19.0, 0.19.1, 0.19.2, 0.20.0, 0.20.1, 0.20.2, 0.20.3, 0.21.0, 0.21.1, 0.22.0, 0.23.0, 0.23.1, 0.23.2, 0.23.3, 0.23.4, 0.24.0, 0.24.1, 0.24.2, 0.25.0, 0.25.1, 0.25.2, 0.25.3, 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.5, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.2.5, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.3.5) ERROR: No matching distribution found for pandas==1.4.1

查看 Pandas 网站,我可以看到他们实际上有一个高达 1.4.1 的版本: https://pandas.pydata.org/pandas-docs/stable/whatsnew/index.html

这可能是问题所在 - 但我仍然想知道雅虎是否已停止使用它 API?

Yahoo API 适合我。不确定您使用的是哪种包装纸(有很多)。 试试 yfinance.

来自 Colab:!pip install yfinance

import yfinance as yf
msft = yf.Ticker("MSFT")
msft.info

很棒的文档 here