The conversion nobody mentions
The Hub Dataset Viewer provides Parquet files for supported datasets. Its Parquet endpoint lists available files and indicates when conversion is partial. Check the split and whether the listed files cover your question.
DuckDB can query remote Parquet files directly. You can count labels or inspect lengths without manually downloading an entire dataset first.
DuckDB, which is free and is one pip install
pip install duckdb requestsimport duckdb
import requests
endpoint = (
"https://datasets-server.huggingface.co/parquet"
)
response = requests.get(
endpoint,
params={"dataset": "stanfordnlp/imdb"},
timeout=20,
)
response.raise_for_status()
payload = response.json()
if payload.get("partial") or payload.get("failed"):
raise RuntimeError("Parquet files are incomplete")
files = payload["parquet_files"]
train = [
item["url"] for item in files
if item["split"] == "train"
and item["config"] == "plain_text"
]
if not train:
raise RuntimeError("No train Parquet files listed")
q = """
SELECT label, COUNT(*) AS n
FROM read_parquet(?)
GROUP BY label
ORDER BY label
"""
print(duckdb.execute(q, [train]).fetchall())Parquet stores columns separately within each row group. DuckDB reads the columns needed by the query. A suitable filter can also let it skip row groups when available statistics rule them out. An unfiltered count by label still needs the label data across the selected files. Transfer size depends on the files, compression and query.
The same API response lists the split, URL and size for each file:
for f in files[:3]:
print(f["split"], f["url"], f["size"])Five questions to ask before downloading
The paths below containing ... are placeholders. Use URLs from the API for the split you want. To query a split with several files, pass the list of URLs to read_parquet as in the example above.
- How big is each class? A dataset described as balanced frequently is not.
SELECT label, COUNT(*)
FROM 'hf://datasets/.../train-*.parquet'
GROUP BY label- How long are the texts? Character counts give a first look. Measure token counts with your intended tokenizer before setting its length limit.
SELECT MIN(len), MAX(len), MEDIAN(len),
QUANTILE_CONT(len, 0.95) AS p95
FROM (SELECT LENGTH(text) AS len FROM '...')- How many extra rows repeat a non-null text?
SELECT COUNT(text) - COUNT(DISTINCT text) AS dupes
FROM '...'- Does the test split overlap the train split? This counts each matching test row once, even if several training rows share that text:
SELECT COUNT(*)
FROM 'hf://datasets/.../test-*.parquet' t
WHERE EXISTS (
SELECT 1 FROM 'hf://datasets/.../train-*.parquet' r
WHERE t.text = r.text
)- What does the rare class actually look like? Pull twenty rows and read them. Ten minutes of reading beats an hour of aggregate statistics, every time.
The viewer itself does more than you think
The dataset page can offer text search, sorting, filters and column statistics. Available features depend on the dataset. Use the viewer for a first look without manually downloading the full dataset.
For example, look for one language dominating a multilingual corpus or for missing entries in a text column.
Turning a query into a view of the whole corpus
One more pattern is worth having. Aggregates answer what is in a dataset; a sample answers what it is like. Combine them:
SELECT label, text
FROM 'hf://datasets/.../train-*.parquet'
USING SAMPLE 20 ROWSThe query returns up to twenty rows for manual inspection. The amount of source data read depends on the sampling method and query plan. Inspecting a sample can reveal formatting, boilerplate and encoding issues that a count alone does not show.
The limits
- Public datasets only by default. Gated and private ones need a token, and very large ones may be only partially converted, which the viewer states.
- Some datasets have no viewer at all: a custom loading script, an unsupported format, or an explicit opt-out. Absence is not a red flag by itself, but it does mean you are back to reading files by hand.
- The parquet copy can lag a very recent update by a short period.
Querying your own files the same way
DuckDB is not a Hub feature; it is a local database that happens to read remote parquet. Everything above works on a folder of your own files:
duckdb.sql(
(
"SELECT COUNT(*) FROM 'data/"
"*.parquet' WHERE lang = 'hi'"
)
)And it goes the other way, straight into the library:
from datasets import Dataset
df = duckdb.sql(
(
"SELECT text, label FROM '...' "
"WHERE LENGTH(text) BETWEEN 50 AND "
"2000"
)
).df()
ds = Dataset.from_pandas(df)SQL for selection and aggregation, datasets for the training path. That combination handles almost everything without Spark, without a cluster, and on hardware you already own.
Do this now
Pick a public dataset with an available Parquet split. Run the relevant queries above using the listed file URLs. Record which split and files you included so another learner can interpret your result.
Check your understanding
A Parquet file has label, text and image columns. What helps an unfiltered query count rows by label without reading the image data?
Pick the one you would defend. Your answer stays private.
Your place and first choices stay on this browser. Classroom credit is recorded separately.
Every lesson here is open. Your progress is recorded once you pass the Image Generation, in Practice exam.
Stuck on something?Ask Arjun, your AI tutor