Vega Datasets

0.9.0 · deprecated · verified Thu Apr 16

A Python package providing convenient access to a collection of over 70 datasets used in Vega, Vega-Lite, and Altair examples and documentation. As of Altair 6.0.0, the `vega-datasets` package has been archived, and its functionality, including all datasets, has been integrated directly into the `altair.datasets` module. The last standalone release of `vega-datasets` was 0.9.0.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates loading the 'cars' dataset using both the deprecated `vega_datasets` import and the recommended `altair.datasets` import for newer Altair versions. The datasets are loaded as Pandas DataFrames.

# Old way (vega-datasets 0.9.0 and earlier)
# Requires: pip install vega-datasets
try:
    from vega_datasets import data
    cars_df_old = data.cars()
    print("Old import (vega-datasets 0.9.0):\n", cars_df_old.head())
    # Accessing metadata
    # print(data.cars.description)
except ImportError:
    print("vega-datasets not installed, skipping old import example.")

# New way (Altair 6.0.0+ with built-in datasets)
# Requires: pip install altair>=6.0.0
try:
    from altair.datasets import data as altair_data
    cars_df_new = altair_data.cars()
    print("\nNew import (Altair 6.0.0+):\n", cars_df_new.head())
    # Accessing metadata
    # print(altair_data.cars.description)
except ImportError:
    print("\nAltair 6.0.0+ not installed or older version. Cannot use new import example.")

view raw JSON →