class_docstr: Spark related features. Usually, the features here are missing in pandas
  but Spark has it.
class_docstr_tok: ["Spark","related","features",".","Usually",",","the","features","here","are","missing","in","pandas","but","Spark","has","it","."]
docstr: Return the current DataFrame as a Spark DataFrame.  :meth:`DataFrame.spark.frame` is an
  alias of  :meth:`DataFrame.to_spark`.
  
  Parameters
  ----------
  index_col: str or list of str, optional, default: None
      Column names to be used in Spark to represent pandas-on-Spark's index. The index name
      in pandas-on-Spark is ignored. By default, the index is always lost.
  
  See Also
  --------
  DataFrame.to_spark
  DataFrame.pandas_api
  DataFrame.spark.frame
  
  Examples
  --------
  By default, this method loses the index as below.
  
  >>> df = ps.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6], 'c': [7, 8, 9]})
  >>> df.to_spark().show()  # doctest: +NORMALIZE_WHITESPACE
  +---+---+---+
  |  a|  b|  c|
  +---+---+---+
  |  1|  4|  7|
  |  2|  5|  8|
  |  3|  6|  9|
  +---+---+---+
  
  >>> df = ps.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6], 'c': [7, 8, 9]})
  >>> df.spark.frame().show()  # doctest: +NORMALIZE_WHITESPACE
  +---+---+---+
  |  a|  b|  c|
  +---+---+---+
  |  1|  4|  7|
  |  2|  5|  8|
  |  3|  6|  9|
  +---+---+---+
  
  If `index_col` is set, it keeps the index column as specified.
  
  >>> df.to_spark(index_col="index").show()  # doctest: +NORMALIZE_WHITESPACE
  +-----+---+---+---+
  |index|  a|  b|  c|
  +-----+---+---+---+
  |    0|  1|  4|  7|
  |    1|  2|  5|  8|
  |    2|  3|  6|  9|
  +-----+---+---+---+
  
  Keeping an index column is useful when you want to call some Spark APIs and
  convert it back to pandas-on-Spark DataFrame without creating a default index, which
  can affect performance.
  
  >>> spark_df = df.to_spark(index_col="index")
  >>> spark_df = spark_df.filter("a == 2")
  >>> spark_df.pandas_api(index_col="index")  # doctest: +NORMALIZE_WHITESPACE
         a  b  c
  index
  1      2  5  8
  
  In case of multi-index, specify a list to `index_col`.
  
  >>> new_df = df.set_index("a", append=True)
  >>> new_spark_df = new_df.to_spark(index_col=["index_1", "index_2"])
  >>> new_spark_df.show()  # doctest: +NORMALIZE_WHITESPACE
  +-------+-------+---+---+
  |index_1|index_2|  b|  c|
  +-------+-------+---+---+
  |      0|      1|  4|  7|
  |      1|      2|  5|  8|
  |      2|      3|  6|  9|
  +-------+-------+---+---+
  
  Can be converted back to pandas-on-Spark DataFrame.
  
  >>> new_spark_df.pandas_api(
  ...     index_col=["index_1", "index_2"])  # doctest: +NORMALIZE_WHITESPACE
                   b  c
  index_1 index_2
  0       1        4  7
  1       2        5  8
  2       3        6  9
docstr_tok: ["Return","the","current","DataFrame","as","a","Spark","DataFrame",".",":","meth",":","`","DataFrame.spark.frame","`","is","an","alias","of",":","meth",":","`","DataFrame.to_spark","`",".","Parameters","--","--","--","--","--","index_col",":","str","or","list","of","str",",","optional",",","default",":","None","Column","names","to","be","used","in","Spark","to","represent","pandas-on-Spark","'s","index",".","The","index","name","in","pandas-on-Spark","is","ignored",".","By","default",",","the","index","is","always","lost",".","See","Also","--","--","--","--","DataFrame.to_spark","DataFrame.pandas_api","DataFrame.spark.frame","Examples","--","--","--","--","By","default",",","this","method","loses","the","index","as","below",".",">",">",">","df","=","ps.DataFrame","(","{","'","a","'",":","[","1",",","2",",","3","]",",","'","b","'",":","[","4",",","5",",","6","]",",","'","c","'",":","[","7",",","8",",","9","]","}",")",">",">",">","df.to_spark","(",")",".show","(",")","#","doctest",":","+NORMALIZE_WHITESPACE","+","--","-+","--","-+","--","-+","|","a|","b|","c|","+","--","-+","--","-+","--","-+","|","1|","4|","7|","|","2|","5|","8|","|","3|","6|","9|","+","--","-+","--","-+","--","-+",">",">",">","df","=","ps.DataFrame","(","{","'","a","'",":","[","1",",","2",",","3","]",",","'","b","'",":","[","4",",","5",",","6","]",",","'","c","'",":","[","7",",","8",",","9","]","}",")",">",">",">","df.spark.frame","(",")",".show","(",")","#","doctest",":","+NORMALIZE_WHITESPACE","+","--","-+","--","-+","--","-+","|","a|","b|","c|","+","--","-+","--","-+","--","-+","|","1|","4|","7|","|","2|","5|","8|","|","3|","6|","9|","+","--","-+","--","-+","--","-+","If","`","index_col","`","is","set",",","it","keeps","the","index","column","as","specified",".",">",">",">","df.to_spark","(","index_col=","''","index","''",")",".show","(",")","#","doctest",":","+NORMALIZE_WHITESPACE","+","--","--","-+","--","-+","--","-+","--","-+","|index|","a|","b|","c|","+","--","--","-+","--","-+","--","-+","--","-+","|","0|","1|","4|","7|","|","1|","2|","5|","8|","|","2|","3|","6|","9|","+","--","--","-+","--","-+","--","-+","--","-+","Keeping","an","index","column","is","useful","when","you","want","to","call","some","Spark","APIs","and","convert","it","back","to","pandas-on-Spark","DataFrame","without","creating","a","default","index",",","which","can","affect","performance",".",">",">",">","spark_df","=","df.to_spark","(","index_col=","''","index","''",")",">",">",">","spark_df","=","spark_df.filter","(","``","a","==","2","''",")",">",">",">","spark_df.pandas_api","(","index_col=","''","index","''",")","#","doctest",":","+NORMALIZE_WHITESPACE","a","b","c","index","1","2","5","8","In","case","of","multi-index",",","specify","a","list","to","`","index_col","`",".",">",">",">","new_df","=","df.set_index","(","``","a","''",",","append=True",")",">",">",">","new_spark_df","=","new_df.to_spark","(","index_col=","[","``","index_1","''",",","``","index_2","''","]",")",">",">",">","new_spark_df.show","(",")","#","doctest",":","+NORMALIZE_WHITESPACE","+","--","--","--","-+","--","--","--","-+","--","-+","--","-+","|index_1|index_2|","b|","c|","+","--","--","--","-+","--","--","--","-+","--","-+","--","-+","|","0|","1|","4|","7|","|","1|","2|","5|","8|","|","2|","3|","6|","9|","+","--","--","--","-+","--","--","--","-+","--","-+","--","-+","Can","be","converted","back","to","pandas-on-Spark","DataFrame",".",">",">",">","new_spark_df.pandas_api","(","...","index_col=","[","``","index_1","''",",","``","index_2","''","]",")","#","doctest",":","+NORMALIZE_WHITESPACE","b","c","index_1","index_2","0","1","4","7","1","2","5","8","2","3","6","9"]
code: def frame(
      self, index_col: Optional[Union[str, List[str]]] = None
  ) -> PySparkDataFrame:
      """
      Return the current DataFrame as a Spark DataFrame.  :meth:`DataFrame.spark.frame` is an
      alias of  :meth:`DataFrame.to_spark`.
  
      Parameters
      ----------
      index_col: str or list of str, optional, default: None
          Column names to be used in Spark to represent pandas-on-Spark's index. The index name
          in pandas-on-Spark is ignored. By default, the index is always lost.
  
      See Also
      --------
      DataFrame.to_spark
      DataFrame.pandas_api
      DataFrame.spark.frame
  
      Examples
      --------
      By default, this method loses the index as below.
  
      >>> df = ps.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6], 'c': [7, 8, 9]})
      >>> df.to_spark().show()  # doctest: +NORMALIZE_WHITESPACE
      +---+---+---+
      |  a|  b|  c|
      +---+---+---+
      |  1|  4|  7|
      |  2|  5|  8|
      |  3|  6|  9|
      +---+---+---+
  
      >>> df = ps.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6], 'c': [7, 8, 9]})
      >>> df.spark.frame().show()  # doctest: +NORMALIZE_WHITESPACE
      +---+---+---+
      |  a|  b|  c|
      +---+---+---+
      |  1|  4|  7|
      |  2|  5|  8|
      |  3|  6|  9|
      +---+---+---+
  
      If `index_col` is set, it keeps the index column as specified.
  
      >>> df.to_spark(index_col="index").show()  # doctest: +NORMALIZE_WHITESPACE
      +-----+---+---+---+
      |index|  a|  b|  c|
      +-----+---+---+---+
      |    0|  1|  4|  7|
      |    1|  2|  5|  8|
      |    2|  3|  6|  9|
      +-----+---+---+---+
  
      Keeping an index column is useful when you want to call some Spark APIs and
      convert it back to pandas-on-Spark DataFrame without creating a default index, which
      can affect performance.
  
      >>> spark_df = df.to_spark(index_col="index")
      >>> spark_df = spark_df.filter("a == 2")
      >>> spark_df.pandas_api(index_col="index")  # doctest: +NORMALIZE_WHITESPACE
             a  b  c
      index
      1      2  5  8
  
      In case of multi-index, specify a list to `index_col`.
  
      >>> new_df = df.set_index("a", append=True)
      >>> new_spark_df = new_df.to_spark(index_col=["index_1", "index_2"])
      >>> new_spark_df.show()  # doctest: +NORMALIZE_WHITESPACE
      +-------+-------+---+---+
      |index_1|index_2|  b|  c|
      +-------+-------+---+---+
      |      0|      1|  4|  7|
      |      1|      2|  5|  8|
      |      2|      3|  6|  9|
      +-------+-------+---+---+
  
      Can be converted back to pandas-on-Spark DataFrame.
  
      >>> new_spark_df.pandas_api(
      ...     index_col=["index_1", "index_2"])  # doctest: +NORMALIZE_WHITESPACE
                       b  c
      index_1 index_2
      0       1        4  7
      1       2        5  8
      2       3        6  9
      """
      from pyspark.pandas.utils import name_like_string
  
      psdf = self._psdf
  
      data_column_names = []
      data_columns = []
      for i, (label, spark_column, column_name) in enumerate(
          zip(
              psdf._internal.column_labels,
              psdf._internal.data_spark_columns,
              psdf._internal.data_spark_column_names,
          )
      ):
          name = str(i) if label is None else name_like_string(label)
          data_column_names.append(name)
          if column_name != name:
              spark_column = spark_column.alias(name)
          data_columns.append(spark_column)
  
      if index_col is None:
          return psdf._internal.spark_frame.select(data_columns)
      else:
          if isinstance(index_col, str):
              index_col = [index_col]
  
          old_index_scols = psdf._internal.index_spark_columns
  
          if len(index_col) != len(old_index_scols):
              raise ValueError(
                  "length of index columns is %s; however, the length of the given "
                  "'index_col' is %s."
                  % (len(old_index_scols), len(index_col))
              )
  
          if any(col in data_column_names for col in index_col):
              raise ValueError(
                  "'index_col' cannot be overlapped with other columns."
              )
  
          new_index_scols = [
              index_scol.alias(col)
              for index_scol, col in zip(old_index_scols, index_col)
          ]
          return psdf._internal.spark_frame.select(
              new_index_scols + data_columns
          )
  
imports: from abc import ABCMeta, abstractmethod
  from typing import TYPE_CHECKING, Callable, Generic, List, Optional, Union
  from pyspark import StorageLevel
  from pyspark.sql import Column, DataFrame
  from pyspark.sql.types import DataType, StructType
  from pyspark.pandas._typing import IndexOpsLike
  from pyspark.pandas.internal import InternalField
  from pyspark.sql.utils import get_column_class, get_dataframe_class
label_desc: Use image node_id 4 for calling the SparkFrameMethods obj's underlying member method code with example usage: obj.frame(index_col) and returns: psdf, psdf