Hugging Face, End to EndLesson 39 of 75

Module 5 · Datasets, and the work that happens before any model

A dataset that behaves like a list and is not one

In this lesson

  • 9 min read
  • 6 reading sections
  • Knowledge check
  • Lesson 2 of 10 in this chapter

This chapter’s goalInspect, stream, filter and transform a dataset far larger than your RAM, query the Hub’s parquet conversion with SQL before downloading anything, run duplicate, leakage and class-balance checks on your own data, and publish it with a card stating provenance and licence.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmWatch2:05Not available
Full audiobookNot availableNot available

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 8Free · no account needed
Lesson steps

Loading, and what comes back

Python
from datasets import load_dataset

ds = load_dataset("imdb")
print(ds)
Text
DatasetDict({
    train: Dataset({features: ['text', 'label'], num_rows: 25000}),
    test:  Dataset({features: ['text', 'label'], num_rows: 25000}),
    unsupervised: Dataset({features: ['text', 'label'], num_rows: 50000}),
})

A DatasetDict is a dictionary of splits. Each Dataset has features (named, typed columns) and a row count. Ask for one split directly and you get the Dataset alone:

Python
train = load_dataset("imdb", split="train")
print(train[0])                    # one row, as a dict
print(train[:3]["text"][0][:80])   # a slice returns a dict of lists
print(train.features)

That last line is worth internalising. Indexing a row gives a dict; slicing gives a dict of lists. train[0] is {'text': ..., 'label': 1}; train[:3] is {'text': [...], 'label': [...]}. Half the confusing errors in a first hour with this library come from expecting a list of dicts.

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

How to cite: Addaly (2026) ‘A dataset that behaves like a list and is not one’, in Hugging Face, End to End. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/hugging-face/the-datasets-library (Accessed: 29 November 2026).