pandas 1.4.2

ParametersReturns
to_frame(self, index: 'bool' = True, name=<no_default>) -> 'DataFrame'

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

Parameters

index : bool, default True

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

name : list / sequence of str, optional

The passed names should substitute index level names.

Returns

DataFrame : a DataFrame containing the original MultiIndex data.

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

See Also

DataFrame

Two-dimensional, size-mutable, potentially heterogeneous tabular data.

Examples

This example is valid syntax, but we were not able to check execution
>>> mi = pd.MultiIndex.from_arrays([['a', 'b'], ['c', 'd']])
... mi MultiIndex([('a', 'c'), ('b', 'd')], )
This example is valid syntax, but we were not able to check execution
>>> df = mi.to_frame()
... df 0 1 a c a c b d b d
This example is valid syntax, but we were not able to check execution
>>> df = mi.to_frame(index=False)
... df 0 1 0 a c 1 b d
This example is valid syntax, but we were not able to check execution
>>> df = mi.to_frame(name=['x', 'y'])
... df x y a c a c b d b d
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/indexes/multi.py#1711
type: <class 'function'>
Commit: