Initializing playground…
← Back to roadmap

Flags: metadata for DataFrame and Series

Mirrors pandas.DataFrame.flags — controls duplicate-label behaviour.

1 · Default flags

Every DataFrame and Series exposes a flags getter returning a Flags object. By default, allowsDuplicateLabels is true.

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

2 · Setting flags

Mutate allowsDuplicateLabels directly on the Flags object. The change is shared across all Flags wrappers for the same underlying object.

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

3 · DuplicateLabelError

Setting allowsDuplicateLabels = false on an object with duplicate index labels immediately throws a DuplicateLabelError.

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

4 · copy() and raiseOnDuplicates()

Flags.copy() returns a new wrapper sharing the same state. raiseOnDuplicates() validates only when allowsDuplicateLabels is false.

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent