cudf.MultiIndex#
- class cudf.MultiIndex(*args, **kwargs)[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
Returns a FrozenList containing the name of the Index.
Number of levels.
Returns list of levels in the MultiIndex
Returns the codes of the underlying MultiIndex.
dtypes
Methods
from_arrays
(arrays[, sortorder, names])Convert arrays to MultiIndex.
from_tuples
(tuples[, sortorder, names])Convert list of tuples to MultiIndex.
from_product
(iterables[, sortorder, names])Make a MultiIndex from the cartesian product of multiple iterables.
from_frame
(df[, sortorder, names])Make a MultiIndex from a DataFrame.
to_frame
([index, name, allow_duplicates])Create a DataFrame with the levels of the MultiIndex as columns.
to_flat_index
()Convert a MultiIndex to an Index of Tuples containing the level values.
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
set_levels
set_codes
sortlevel
reorder_levels
remove_unused_levels
get_loc
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')], )