cudf.MultiIndex.from_tuples#

classmethod MultiIndex.from_tuples(tuples, sortorder: int | None = None, names=None) Self[source]#

将元组列表转换为MultiIndex。

Parameters:
tupleslist / sequence of tuple-likes

每个元组是一行/列的索引。

sortorderint or None

排序级别(必须按该级别按字典顺序排序)。

nameslist / sequence of str, optional

索引中级别的名称。

Returns:
MultiIndex

另请参阅

MultiIndex.from_arrays

将数组列表转换为MultiIndex。

MultiIndex.from_product

从可迭代对象的笛卡尔积创建一个MultiIndex。

MultiIndex.from_frame

从DataFrame创建一个MultiIndex。

示例

>>> tuples = [(1, 'red'), (1, 'blue'),
...           (2, 'red'), (2, 'blue')]
>>> cudf.MultiIndex.from_tuples(tuples, names=('number', 'color'))
MultiIndex([(1,  'red'),
            (1, 'blue'),
            (2,  'red'),
            (2, 'blue')],
           names=['number', 'color'])