You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用pandas_datareader调用Yahoo接口获取数据遇弃用错误求助

Fix for Yahoo API Deprecation Error in pandas_datareader

Hey there! That error you're hitting is super common right now—Yahoo made major changes to their financial API that completely broke the pandas_datareader Yahoo connector, and there’s no stable replacement built into the library at the moment.

Luckily, there’s a straightforward workaround using the yfinance library, which was specifically built to fill this gap. Here’s how to fix your code:

Step 1: Install yfinance

First, install the library via pip if you haven’t already:

pip install yfinance

Step 2: Update Your Code

Replace your existing pandas_datareader import and data-fetching code with this:

import numpy as np
import datetime
import pandas as pd
import yfinance as yf

start = datetime.datetime(2017, 1, 1)
end = datetime.datetime(2017, 12, 31)
AAPL = yf.download('AAPL', start=start, end=end)

Why This Works

yfinance maintains an up-to-date connection to Yahoo’s financial data endpoints, and it returns data in the exact same pandas DataFrame format that pandas_datareader used. That means you can keep using all your existing data-processing code without major tweaks.

If you were set on using pandas_datareader directly, note that the project maintainers have said they welcome pull requests to re-enable the Yahoo connector—but there’s no timeline for a fix. So yfinance is the most reliable option right now.

内容的提问来源于stack exchange,提问作者Namish Mishra

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 07:03:53