cudf.MultiIndex#

class cudf.MultiIndex(levels=None, codes=None, sortorder=None, names=None, dtype=None, copy=False, name=None, verify_integrity=True)[source]#

A multi-level or hierarchical index.

Provides N-Dimensional indexing into Series and DataFrame objects.

Parameters:
levelssequence of arrays

The unique labels for each level.

codes: sequence of arrays

Integers for each level designating which label at each location.

sortorderoptional int

Not yet supported

names: optional sequence of objects

Names for each of the index levels.

copybool, default False

Copy the levels and codes.

verify_integritybool, default True

Check that the levels/codes are consistent and valid. Not yet supported

Attributes

names

Returns a FrozenList containing the name of the Index.

nlevels

Integer number of levels in this MultiIndex.

levels

Returns list of levels in the MultiIndex

codes

Returns the codes of the underlying MultiIndex.

dtypes

Methods

from_arrays(arrays[, sortorder, names])

Convert arrays to MultiIndex.

from_tuples(tuples[, names])

Convert list of tuples to MultiIndex.

from_product(arrays[, names])

Make a MultiIndex from the cartesian product of multiple iterables.

from_frame(df[, names])

Make a MultiIndex from a DataFrame.

to_frame([index, name, allow_duplicates])

Create a DataFrame with the levels of the MultiIndex as columns.

droplevel([level])

Removes the specified levels from the MultiIndex.

swaplevel([i, j])

Swap level i with level j.

get_level_values(level)

Return the values at the requested level

get_loc(key)

Get integer location, slice or boolean mask for requested label.

set_levels

set_codes

to_flat_index

sortlevel

reorder_levels

remove_unused_levels

drop

Returns:
MultiIndex

Examples

>>> import cudf
>>> cudf.MultiIndex(
... levels=[[1, 2], ['blue', 'red']], codes=[[0, 0, 1, 1], [1, 0, 1, 0]])
MultiIndex([(1,  'red'),
            (1, 'blue'),
            (2,  'red'),
            (2, 'blue')],
           )