code: def test_from_pandas(self):
      pdf = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
  
      internal = InternalFrame.from_pandas(pdf)
      sdf = internal.spark_frame
  
      self.assert_eq(
          internal.index_spark_column_names, [SPARK_DEFAULT_INDEX_NAME]
      )
      self.assert_eq(internal.index_names, [None])
      self.assert_eq(internal.column_labels, [("a",), ("b",)])
      self.assert_eq(internal.data_spark_column_names, ["a", "b"])
      self.assertTrue(
          spark_column_equals(
              internal.spark_column_for(("a",)), sdf["a"]
          )
      )
      self.assertTrue(
          spark_column_equals(
              internal.spark_column_for(("b",)), sdf["b"]
          )
      )
  
      self.assert_eq(internal.to_pandas_frame, pdf)
  
      # non-string column name
      pdf1 = pd.DataFrame({0: [1, 2, 3], 1: [4, 5, 6]})
  
      internal = InternalFrame.from_pandas(pdf1)
      sdf = internal.spark_frame
  
      self.assert_eq(
          internal.index_spark_column_names, [SPARK_DEFAULT_INDEX_NAME]
      )
      self.assert_eq(internal.index_names, [None])
      self.assert_eq(internal.column_labels, [(0,), (1,)])
      self.assert_eq(internal.data_spark_column_names, ["0", "1"])
      self.assertTrue(
          spark_column_equals(internal.spark_column_for((0,)), sdf["0"])
      )
      self.assertTrue(
          spark_column_equals(internal.spark_column_for((1,)), sdf["1"])
      )
  
      self.assert_eq(internal.to_pandas_frame, pdf1)
  
      # categorical column
      pdf2 = pd.DataFrame({0: [1, 2, 3], 1: pd.Categorical([4, 5, 6])})
      internal = InternalFrame.from_pandas(pdf2)
      sdf = internal.spark_frame
  
      self.assert_eq(
          internal.index_spark_column_names, [SPARK_DEFAULT_INDEX_NAME]
      )
      self.assert_eq(internal.index_names, [None])
      self.assert_eq(internal.column_labels, [(0,), (1,)])
      self.assert_eq(internal.data_spark_column_names, ["0", "1"])
      self.assertTrue(
          spark_column_equals(internal.spark_column_for((0,)), sdf["0"])
      )
      self.assertTrue(
          spark_column_equals(internal.spark_column_for((1,)), sdf["1"])
      )
  
      self.assert_eq(internal.to_pandas_frame, pdf2)
  
      # multi-index
      pdf.set_index("a", append=True, inplace=True)
  
      internal = InternalFrame.from_pandas(pdf)
      sdf = internal.spark_frame
  
      self.assert_eq(
          internal.index_spark_column_names,
          [SPARK_INDEX_NAME_FORMAT(0), SPARK_INDEX_NAME_FORMAT(1)],
      )
      self.assert_eq(internal.index_names, [None, ("a",)])
      self.assert_eq(internal.column_labels, [("b",)])
      self.assert_eq(internal.data_spark_column_names, ["b"])
      self.assertTrue(
          spark_column_equals(
              internal.spark_column_for(("b",)), sdf["b"]
          )
      )
  
      self.assert_eq(internal.to_pandas_frame, pdf)
  
      # multi-index columns
      pdf.columns = pd.MultiIndex.from_tuples([("x", "b")])
  
      internal = InternalFrame.from_pandas(pdf)
      sdf = internal.spark_frame
  
      self.assert_eq(
          internal.index_spark_column_names,
          [SPARK_INDEX_NAME_FORMAT(0), SPARK_INDEX_NAME_FORMAT(1)],
      )
      self.assert_eq(internal.index_names, [None, ("a",)])
      self.assert_eq(internal.column_labels, [("x", "b")])
      self.assert_eq(internal.data_spark_column_names, ["(x, b)"])
      self.assertTrue(
          spark_column_equals(
              internal.spark_column_for(("x", "b")), sdf["(x, b)"]
          )
      )
  
      self.assert_eq(internal.to_pandas_frame, pdf)
  
file_path: spark/python/pyspark/pandas/tests/test_internal.py
imports: import pandas
  from pyspark.pandas.internal import InternalFrame, SPARK_DEFAULT_INDEX_NAME, SPARK_INDEX_NAME_FORMAT
  from pyspark.pandas.utils import spark_column_equals
  from pyspark.testing.pandasutils import PandasOnSparkTestCase
  from pyspark.testing.sqlutils import SQLTestUtils
label_desc: Use image node_id 1 for calling the InternalFrameTestsMixin obj's underlying member method code with example usage: obj.test_from_pandas() without return types