---
title: "Hugging Face Datasets features: column types, ClassLabel and cast"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source: https://iinventedlight.com/library/notes/hf-datasets-features-casting.md
source_license: "Apache-2.0 (huggingface/datasets docs); restated in our own words"
attribution: "Summary by iinventedlight (AI-assisted). Sources: Hugging Face (Datasets docs), Dataset features · Hugging Face, Apache-2.0 (huggingface/datasets docs); Hugging Face (Datasets docs), Process · Hugging Face, Apache-2.0 (huggingface/datasets docs)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-04
status: published
checked_on: 2026-11-04
as_of: 2026-11-04
confidence: medium
untested: "No code was run; only the fetched Hugging Face documentation pages were read."
category: huggingface-datasets
topic_area: "datasets: schema"
tags: huggingface, datasets, features, schema
sources:
  - id: S1
    title: "Dataset features · Hugging Face"
    publisher: Hugging Face (Datasets docs)
    url: https://huggingface.co/docs/datasets/about_dataset_features
    accessed: 2026-11-04
    license: "Apache-2.0 (huggingface/datasets docs)"
  - id: S2
    title: "Process · Hugging Face"
    publisher: Hugging Face (Datasets docs)
    url: https://huggingface.co/docs/datasets/process
    accessed: 2026-11-04
    license: "Apache-2.0 (huggingface/datasets docs)"
---
# Hugging Face Datasets features: column types, ClassLabel and cast

## Short answer
`dataset.features` is a dict of column name to column type. It tells you, for example, that a label column is a `ClassLabel` with named classes stored as integers. Change types with `cast()` or `cast_column()`, which return a new dataset. [S1][S2]

## Example
```python
from datasets import ClassLabel, Value
ds = ds.cast_column("label", ClassLabel(names=["neg", "pos"]))
print(ds.features)
```
Use `List` for list-valued columns and nested dicts for structured fields. [S1]

## Claims
- id: C1
  claim: Features defines a dataset's internal structure.
  source: S1
  evidence: "Features defines the internal structure of a dataset."
- id: C2
  claim: The Features format is a dict of column name to type.
  source: S1
  evidence: "It is a dictionary of column name and column type pairs."
- id: C3
  claim: ClassLabel labels are stored as integers.
  source: S1
  evidence: "Labels are stored as integers in the dataset."
- id: C4
  claim: cast transforms the feature type of columns.
  source: S2
  evidence: "function transforms the feature type of one or more columns"
- id: C5
  claim: Processing methods return a new Dataset, not in-place.
  source: S2
  evidence: "Modification is not done in-place."

## Sources
- [S1] Dataset features · Hugging Face. Hugging Face (Datasets docs). https://huggingface.co/docs/datasets/about_dataset_features . License: Apache-2.0 (huggingface/datasets docs). Accessed 2026-11-04.
- [S2] Process · Hugging Face. Hugging Face (Datasets docs). https://huggingface.co/docs/datasets/process . License: Apache-2.0 (huggingface/datasets docs). Accessed 2026-11-04.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
