pandas-datareader
Data readers extracted from the pandas codebase, pandas-datareader provides up-to-date remote data access for various financial and economic data sources, compatible with recent pandas versions. The library's release cadence is irregular, largely influenced by the frequent changes in external data provider APIs which often require rapid updates to its readers.
Warnings
- breaking Dropped support for Python 2.7 in v0.9.0. The minimum required Python version is now 3.6.
- breaking IEX Cloud API Key Requirement: From v0.8.0, all IEX readers require an API token (`IEX_API_KEY`).
- breaking Removal or immediate deprecation of several data sources: Google Finance, Morningstar, and Robinhood were removed (deprecated in v0.7.0, removed in v0.8.0, Robinhood removed in v0.9.0). The AlphaVantage quote reader and Enigma were immediately deprecated in v0.9.0 due to API changes or service termination.
- gotcha Yahoo Finance reader instability: The Yahoo Finance API is prone to frequent, unannounced changes, often leading to `RemoteDataError` or incorrect data. While v0.10.0 included fixes for Yahoo readers, it remains a common point of failure for users.
- gotcha General API instability and lack of frequent updates: Many data sources continuously change their APIs, causing readers in `pandas-datareader` to break. There is an acknowledged challenge in maintaining all readers, leading to periods where certain data sources may not function correctly between releases.
- gotcha Potential incompatibility with Pandas 3.0: There are indications of anticipated breaking changes related to `pandas` 3.0. Users upgrading `pandas` to version 3.0 or higher may encounter issues.
Install
-
pip install pandas-datareader
Imports
- DataReader
from pandas_datareader.data import DataReader
- pandas_datareader as pdr
import pandas_datareader as pdr
- pandas_datareader.data as web
import pandas_datareader.data as web
Quickstart
import pandas_datareader.data as web
import datetime
start = datetime.datetime(2020, 1, 1)
end = datetime.datetime(2023, 1, 1)
# Fetch data from FRED (Federal Reserve Economic Data)
gs10 = web.DataReader('GS10', 'fred', start, end)
print(gs10.head())