Skip to content

Accessing Data using Python #89

Closed as not planned
Closed as not planned

Description

@mmcky

This is a general note for accessing data using python.

The best starting place is to use pandas.datareader but it is relatively slow to update and isn't always the most convenient way to access data. Sometimes it can be beneficial to use a custom library that is more tightly integrated with the api that is offered such as for the WDI.

If we can use datareader it will simplify dependencies

It supports data from these sources

Some other avenues are:

Fred

  1. Directly via the API
  2. https://github.com/mortada/fredapi

Penn World Tables

The PWT dataset is only ~6Mb so I typically download it as an Excel file and then use pandas to read in the information I need

World Development Indicators (WDI) by World Bank

  1. https://data.worldbank.org/products/third-party-apps
  2. https://blogs.worldbank.org/opendata/introducing-wbgapi-new-python-package-accessing-world-bank-data

Activity

  1. mmcky commented on Jul 29, 2026

    @mmcky
    ContributorAuthor

    Closing as not planned — this issue records an orientation note rather than a unit of work, and the question it raises has moved to a repo that now owns it.

    The recommendation here was reversed, but only partly. This issue's starting point is that "the best starting place is to use pandas.datareader" and that standardising on it "will simplify dependencies". lecture-python-programming#341, merged 2025-03-12, did the opposite: it removed pandas_datareader and replaced it with wbgapi, on the grounds that pandas_datareader was not receiving updates. wbgapi is one of the alternatives listed in this very issue under World Development Indicators, so the org kept an alternative and dropped the recommended default.

    That change was never carried across the rest of the series. Seven published lectures still install and import pandas_datareader at execution time: unemployment_linear, unemployment_shocks, phillips_lost_conquest and phillips_two_stories in lecture-python.myst; business_cycle in lecture-python-intro, which uses wbgapi and pandas_datareader side by side; and tools/classification and tools/visualization_rules in lecture-datascience.myst.

    And the reason for the reversal no longer holds. pandas-datareader released 0.11.0 on 2026-06-23 and 0.11.1 on 2026-06-24, after five years without a release. 0.11.0 restores pandas 3 compatibility — it vendors deprecate_kwarg to drop the dependency on private pandas internals, which is precisely the breakage recorded in QuantEcon/lecture-python.myst#924 — and adds a pandas_datareader.macro API giving unified access to FRED, Eurostat and OECD series. So the package is maintained again, and the seven remaining usages are not currently broken.

    Where the question goes. Data access is no longer a meta concern: it belongs with the vendored-data programme in data-lectures, whose routing rule is that data consumed by lectures lives there behind a stable URL. The specific opportunity — using pandas_datareader as a common builder-side entry point for dynamic data, rather than a runtime import in each lecture — is now QuantEcon/data-lectures#26, where it connects to the UNRATE dynamic-snapshot pilot and the scheduled-refresh and canary work already planned there.

    The per-source pointers this issue collected (FRED, Penn World Tables, WDI) are captured by that programme's per-dataset manifests, which record source, licence and cadence properly — a better home than a standing note here.

    Related: #160 remains open as the standing pandas_datareader deprecation issue, and its premise is now out of date for the reasons above.

    Disposition tracked in #344.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions