class_docstr: pandas-on-Spark MultiIndex that corresponds to pandas MultiIndex logically. This might hold
  Spark Column internally.
  
  Parameters
  ----------
  levels : sequence of arrays
      The unique labels for each level.
  codes : sequence of arrays
      Integers for each level designating which label at each location.
  sortorder : optional int
      Level of sortedness (must be lexicographically sorted by that
      level).
  names : optional sequence of objects
      Names for each of the index levels. (name is accepted for compat).
  copy : bool, default False
      Copy the meta-data.
  verify_integrity : bool, default True
      Check that the levels/codes are consistent and valid.
  
  See Also
  --------
  MultiIndex.from_arrays  : Convert list of arrays to MultiIndex.
  MultiIndex.from_product : Create a MultiIndex from the cartesian product
                            of iterables.
  MultiIndex.from_tuples  : Convert list of tuples to a MultiIndex.
  MultiIndex.from_frame   : Make a MultiIndex from a DataFrame.
  Index : A single-level Index.
  
  Examples
  --------
  >>> ps.DataFrame({'a': ['a', 'b', 'c']}, index=[[1, 2, 3], [4, 5, 6]]).index  # doctest: +SKIP
  MultiIndex([(1, 4),
              (2, 5),
              (3, 6)],
             )
  
  >>> ps.DataFrame({'a': [1, 2, 3]}, index=[list('abc'), list('def')]).index  # doctest: +SKIP
  MultiIndex([('a', 'd'),
              ('b', 'e'),
              ('c', 'f')],
             )
class_docstr_tok: ["pandas-on-Spark","MultiIndex","that","corresponds","to","pandas","MultiIndex","logically",".","This","might","hold","Spark","Column","internally",".","Parameters","--","--","--","--","--","levels",":","sequence","of","arrays","The","unique","labels","for","each","level",".","codes",":","sequence","of","arrays","Integers","for","each","level","designating","which","label","at","each","location",".","sortorder",":","optional","int","Level","of","sortedness","(","must","be","lexicographically","sorted","by","that","level",")",".","names",":","optional","sequence","of","objects","Names","for","each","of","the","index","levels",".","(","name","is","accepted","for","compat",")",".","copy",":","bool",",","default","False","Copy","the","meta-data",".","verify_integrity",":","bool",",","default","True","Check","that","the","levels\/codes","are","consistent","and","valid",".","See","Also","--","--","--","--","MultiIndex.from_arrays",":","Convert","list","of","arrays","to","MultiIndex",".","MultiIndex.from_product",":","Create","a","MultiIndex","from","the","cartesian","product","of","iterables",".","MultiIndex.from_tuples",":","Convert","list","of","tuples","to","a","MultiIndex",".","MultiIndex.from_frame",":","Make","a","MultiIndex","from","a","DataFrame",".","Index",":","A","single-level","Index",".","Examples","--","--","--","--",">",">",">","ps.DataFrame","(","{","'","a","'",":","[","'","a","'",",","'","b","'",",","'","c","'","]","}",",","index=","[","[","1",",","2",",","3","]",",","[","4",",","5",",","6","]","]",")",".index","#","doctest",":","+SKIP","MultiIndex","(","[","(","1",",","4",")",",","(","2",",","5",")",",","(","3",",","6",")","]",",",")",">",">",">","ps.DataFrame","(","{","'","a","'",":","[","1",",","2",",","3","]","}",",","index=","[","list","(","'abc","'",")",",","list","(","'def","'",")","]",")",".index","#","doctest",":","+SKIP","MultiIndex","(","[","(","'","a","'",",","'d","'",")",",","(","'","b","'",",","'","e","'",")",",","(","'","c","'",",","'","f","'",")","]",",",")"]
docstr: 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
  ----------
  index : boolean, default True
      Set the index of the returned DataFrame as the original MultiIndex.
  name : list / sequence of strings, optional
      The passed names should substitute index level names.
  
  Returns
  -------
  DataFrame : a DataFrame containing the original MultiIndex data.
  
  See Also
  --------
  DataFrame
  
  Examples
  --------
  >>> tuples = [(1, 'red'), (1, 'blue'),
  ...           (2, 'red'), (2, 'blue')]
  >>> idx = ps.MultiIndex.from_tuples(tuples, names=('number', 'color'))
  >>> idx  # doctest: +SKIP
  MultiIndex([(1,  'red'),
              (1, 'blue'),
              (2,  'red'),
              (2, 'blue')],
             names=['number', 'color'])
  >>> idx.to_frame()  # doctest: +NORMALIZE_WHITESPACE
                number color
  number color
  1      red         1   red
         blue        1  blue
  2      red         2   red
         blue        2  blue
  
  By default, the original Index is reused. To enforce a new Index:
  
  >>> idx.to_frame(index=False)
     number color
  0       1   red
  1       1  blue
  2       2   red
  3       2  blue
  
  To override the name of the resulting column, specify `name`:
  
  >>> idx.to_frame(name=['n', 'c'])  # doctest: +NORMALIZE_WHITESPACE
                n     c
  number color
  1      red    1   red
         blue   1  blue
  2      red    2   red
         blue   2  blue
docstr_tok: ["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","--","--","--","--","--","index",":","boolean",",","default","True","Set","the","index","of","the","returned","DataFrame","as","the","original","MultiIndex",".","name",":","list","\/","sequence","of","strings",",","optional","The","passed","names","should","substitute","index","level","names",".","Returns","--","--","--","-","DataFrame",":","a","DataFrame","containing","the","original","MultiIndex","data",".","See","Also","--","--","--","--","DataFrame","Examples","--","--","--","--",">",">",">","tuples","=","[","(","1",",","'red","'",")",",","(","1",",","'blue","'",")",",","...","(","2",",","'red","'",")",",","(","2",",","'blue","'",")","]",">",">",">","idx","=","ps.MultiIndex.from_tuples","(","tuples",",","names=","(","'number","'",",","'color","'",")",")",">",">",">","idx","#","doctest",":","+SKIP","MultiIndex","(","[","(","1",",","'red","'",")",",","(","1",",","'blue","'",")",",","(","2",",","'red","'",")",",","(","2",",","'blue","'",")","]",",","names=","[","'number","'",",","'color","'","]",")",">",">",">","idx.to_frame","(",")","#","doctest",":","+NORMALIZE_WHITESPACE","number","color","number","color","1","red","1","red","blue","1","blue","2","red","2","red","blue","2","blue","By","default",",","the","original","Index","is","reused",".","To","enforce","a","new","Index",":",">",">",">","idx.to_frame","(","index=False",")","number","color","0","1","red","1","1","blue","2","2","red","3","2","blue","To","override","the","name","of","the","resulting","column",",","specify","`","name","`",":",">",">",">","idx.to_frame","(","name=","[","'n","'",",","'","c","'","]",")","#","doctest",":","+NORMALIZE_WHITESPACE","n","c","number","color","1","red","1","red","blue","1","blue","2","red","2","red","blue","2","blue"]
code: def to_frame(  # type: ignore[override]
      self, index: bool = True, name: Optional[List[Name]] = None
  ) -> DataFrame:
      """
      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
      ----------
      index : boolean, default True
          Set the index of the returned DataFrame as the original MultiIndex.
      name : list / sequence of strings, optional
          The passed names should substitute index level names.
  
      Returns
      -------
      DataFrame : a DataFrame containing the original MultiIndex data.
  
      See Also
      --------
      DataFrame
  
      Examples
      --------
      >>> tuples = [(1, 'red'), (1, 'blue'),
      ...           (2, 'red'), (2, 'blue')]
      >>> idx = ps.MultiIndex.from_tuples(tuples, names=('number', 'color'))
      >>> idx  # doctest: +SKIP
      MultiIndex([(1,  'red'),
                  (1, 'blue'),
                  (2,  'red'),
                  (2, 'blue')],
                 names=['number', 'color'])
      >>> idx.to_frame()  # doctest: +NORMALIZE_WHITESPACE
                    number color
      number color
      1      red         1   red
             blue        1  blue
      2      red         2   red
             blue        2  blue
  
      By default, the original Index is reused. To enforce a new Index:
  
      >>> idx.to_frame(index=False)
         number color
      0       1   red
      1       1  blue
      2       2   red
      3       2  blue
  
      To override the name of the resulting column, specify `name`:
  
      >>> idx.to_frame(name=['n', 'c'])  # doctest: +NORMALIZE_WHITESPACE
                    n     c
      number color
      1      red    1   red
             blue   1  blue
      2      red    2   red
             blue   2  blue
      """
      if name is None:
          name = [
              name if name is not None else (i,)
              for i, name in enumerate(self._internal.index_names)
          ]
      elif is_list_like(name):
          if len(name) != self._internal.index_level:
              raise ValueError(
                  "'name' should have same length as number of levels on index."
              )
          name = [n if is_name_like_tuple(n) else (n,) for n in name]
      else:
          raise TypeError(
              "'name' must be a list / sequence of column names."
          )
  
      return self._to_frame(index=index, names=name)
  
imports: from functools import partial, reduce
  from typing import Any, Callable, Iterator, List, Optional, Tuple, Union, cast, no_type_check
  import pandas
  from pandas.api.types import is_hashable, is_list_like
  from pyspark.sql import functions, Column, Window
  from pyspark.sql.types import DataType
  from pyspark.sql.utils import get_column_class
  from pyspark import pandas
  from pyspark.pandas._typing import Label, Name, Scalar
  from pyspark.pandas.exceptions import PandasNotImplementedError
  from pyspark.pandas.frame import DataFrame
  from pyspark.pandas.indexes.base import Index
  from pyspark.pandas.missing.indexes import MissingPandasLikeMultiIndex
  from pyspark.pandas.series import Series, first_series
  from pyspark.pandas.utils import compare_disallow_null, is_name_like_tuple, name_like_string, scol_for, verify_temp_column_name, validate_index_loc, xor
  from pyspark.pandas.internal import InternalField, InternalFrame, NATURAL_ORDER_COLUMN_NAME, SPARK_INDEX_NAME_FORMAT
label_desc: Use image node_id 23 for calling the MultiIndex obj's underlying member method code with example usage: obj.to_frame(index, name) and returns: self