Hierarchical multi-level index — mirrors
pandas.MultiIndex. Build composite keys from tuples, arrays,
or Cartesian products and use them for advanced label-based look-ups.
Edit any code block below and press ▶ Run
(or Ctrl+Enter) to execute it live in your browser.
The most common way: pass an array of label-tuples.
Supply one array per level — a column-oriented alternative to
fromTuples.
fromProduct generates every combination from a list of
iterables — very handy for experiment grids.
Use getLoc to find the position of a tuple.
contains for a quick existence check.
Restructure the level hierarchy without touching the data.
union, intersection, difference —
same semantics as pandas.MultiIndex.
Sort tuples lexicographically and detect or remove duplicates.
Detect and remove tuples that contain null or
undefined in any level.
Key static constructors and instance methods on
MultiIndex.
// Static constructors
MultiIndex.fromTuples(tuples, { names? }): MultiIndex
MultiIndex.fromArrays(arrays, { names? }): MultiIndex
MultiIndex.fromProduct(iterables, { names? }): MultiIndex
// Properties
mi.nlevels: number // number of levels
mi.size: number // number of entries
mi.names: string[] // level names
// Look-up
mi.at(i): unknown[] // tuple at position
mi.getLoc(tuple): number | number[] // position(s) of tuple
mi.contains(tuple): boolean // existence check
// Restructure
mi.droplevel(level): MultiIndex | Index
mi.swaplevel(i, j): MultiIndex
// Set operations
mi.union(other): MultiIndex
mi.intersection(other): MultiIndex
mi.difference(other): MultiIndex
// Sorting & deduplication
mi.sortValues(): MultiIndex
mi.dropDuplicates(): MultiIndex
mi.duplicated(keep?): boolean[]
// Missing values
mi.isna(): boolean[]
mi.dropna(): MultiIndex