cudf.MultiIndex.to_frame#

MultiIndex.to_frame(index=True, name=_NoDefault.no_default, allow_duplicates=False)[source]#

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

Column ordering is determined by the DataFrame constructor with data as a dict.

Parameters:
indexbool, default True

Set the index of the returned DataFrame as the original MultiIndex.

namelist / sequence of str, optional

The passed names should substitute index level names.

allow_duplicatesbool, optional default False

Allow duplicate column labels to be created. Note that this parameter is non-functional because duplicates column labels aren’t supported in cudf.

Returns:
DataFrame

Examples

>>> import cudf
>>> mi = cudf.MultiIndex.from_tuples([('a', 'c'), ('b', 'd')])
>>> mi
MultiIndex([('a', 'c'),
            ('b', 'd')],
           )
>>> df = mi.to_frame()
>>> df
     0  1
a c  a  c
b d  b  d
>>> df = mi.to_frame(index=False)
>>> df
   0  1
0  a  c
1  b  d
>>> df = mi.to_frame(name=['x', 'y'])
>>> df
     x  y
a c  a  c
b d  b  d