Create a DataFrame with the levels of the MultiIndex as columns.
Column ordering is determined by the DataFrame constructor with data as a dict.
Set the index of the returned DataFrame as the original MultiIndex.
The passed names should substitute index level names.
Allow duplicate column labels to be created.
Added in version 1.5.0.
See also
DataFrame
Two-dimensional, size-mutable, potentially heterogeneous tabular data.
Examples
>>> mi = pd.MultiIndex.from_arrays([['a', 'b'], ['c', '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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4