Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Huggingface Datasets Value

From Leeroopedia
Knowledge Sources
Domains Data_Engineering, NLP
Last Updated 2026-02-14 18:00 GMT

Overview

Concrete tool for representing scalar data types in dataset schemas provided by the HuggingFace Datasets library.

Description

Value is a dataclass that represents a scalar feature value of a particular data type. It accepts a dtype string at construction and converts it to the corresponding PyArrow type. Supported dtypes include: null, bool, int8-int64, uint8-uint64, float16-float64, string, large_string, string_view, binary, large_binary, binary_view, date32, date64, time32, time64, timestamp, duration, decimal128, and decimal256. Aliases "float" and "double" are normalized to "float32" and "float64" respectively.

Usage

Use Value to define the type of any scalar column in a Features schema. It is the most commonly used feature type.

Code Reference

Source Location

  • Repository: datasets
  • File: src/datasets/features/features.py
  • Lines: 490-573

Signature

@dataclass
class Value:
    dtype: str
    id: Optional[str] = field(default=None, repr=False)
    # Automatically constructed
    pa_type: ClassVar[Any] = None
    _type: str = field(default="Value", init=False, repr=False)

Import

from datasets import Value

I/O Contract

Inputs

Name Type Required Description
dtype str Yes Name of the data type (e.g., "int32", "string", "float64").
id str No Optional identifier for the feature.

Outputs

Name Type Description
instance Value A Value feature with the corresponding PyArrow type set in pa_type.

Usage Examples

Basic Usage

from datasets import Features, Value

features = Features({
    "stars": Value("int32"),
    "text": Value("string"),
    "score": Value("float64"),
})
print(features)
# {'stars': Value('int32'), 'text': Value('string'), 'score': Value('float64')}

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment