Install & Compatibility
Where this runs
tested against v0.0.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 1.000s · 164.9MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 7.6s · import 0.939s · 157MB
164MB installed
● package 164MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
fetch_ucirepo
✓ from ucimlrepo import fetch_ucirepo
✗ import ucimlrepo.fetch_ucirepo
The primary function `fetch_ucirepo` is directly available in the top-level package.
This quickstart demonstrates how to fetch a dataset using its unique ID, access its features and targets as pandas DataFrames, and retrieve metadata and variable information. Replace `id=53` with the ID of any dataset from the UCI ML Repository.
from ucimlrepo import fetch_ucirepo
# Fetch a dataset by its ID (e.g., Iris dataset, ID 53)
iris_dataset = fetch_ucirepo(id=53)
# Access features (X) and targets (y) as pandas DataFrames
X = iris_dataset.data.features
y = iris_dataset.data.targets
print("Features (X) head:\n", X.head())
print("Targets (y) head:\n", y.head())
# Access metadata and variable information
print("\nMetadata:\n", iris_dataset.metadata)
print("\nVariable Info:\n", iris_dataset.variables)
Debug
Known issues
breakingThe library is in early development (version 0.0.x). While efforts are made for stability, API changes, particularly in the structure of the returned dataset object attributes (e.g., `dataset.data`, `dataset.metadata`, `dataset.variables`), may occur without a major version increment.fixConsult the latest documentation or GitHub README for the exact object structure after an upgrade. Pin your dependency version if stability is critical for your project (e.g., `ucimlrepo==0.0.7`).
affects: All 0.0.x versions
gotchaAll fetched dataset features (`.data.features`) and targets (`.data.targets`) are consistently returned as `pandas.DataFrame` objects. Users should be prepared to work with pandas, or convert the data to NumPy arrays or other formats explicitly.fixEnsure `pandas` is installed (`pip install pandas`). If you prefer NumPy arrays, convert them using the `.values` attribute (e.g., `X.values`).
affects: All versions
gotchaDatasets are primarily accessed by their unique integer `id` (e.g., `fetch_ucirepo(id=53)`). While the repository offers names, programmatic access relies on these IDs. Incorrect IDs will result in an error.fixFind the desired dataset's ID from the UCI ML Repository website or by using `ucimlrepo.list_available_datasets()` (if implemented and available in your version) to get a list of IDs and names.
affects: All versions
Errors
Common errors & fixes
AttributeError: 'UCI_ML_Repo' object has no attribute 'data' (or 'features', 'targets')
Attempting to access attributes like `data`, `features`, or `targets` directly on the object returned by `fetch_ucirepo`.
fixThe data attributes are nested. Access features as `dataset_obj.data.features` and targets as `dataset_obj.data.targets`.
ModuleNotFoundError: No module named 'pandas'
`ucimlrepo` depends on `pandas` to return dataset features and targets as DataFrames, but `pandas` is not installed in the current Python environment.
fixInstall the `pandas` library: `pip install pandas`.
ValueError: No dataset found with id X
The provided dataset ID (X) does not correspond to an existing dataset in the UCI ML Repository, or there was a typo in the ID.
fixVerify the dataset ID on the official UCI ML Repository website or consult `ucimlrepo.list_available_datasets()` if your version of the library supports listing available datasets to find the correct ID.
Upgrade
Version history
0.0.7latest on PyPI · released May 21, 2024
Audit
Dependencies
pandasrequiredRequired for returning dataset features and targets as DataFrame objects.