code: def test_creation_index(self):
      data = np.random.randn(5, 3)
  
      # test local data with pd.Index
      self.assert_eq(
          ps.DataFrame(data=[1, 2], index=pd.Index([1, 2])),
          pd.DataFrame(data=[1, 2], index=pd.Index([1, 2])),
      )
      self.assert_eq(
          ps.DataFrame(data=[1, 2], index=pd.Index([2, 3])),
          pd.DataFrame(data=[1, 2], index=pd.Index([2, 3])),
      )
      self.assert_eq(
          ps.DataFrame(data=[1, 2], index=pd.Index([3, 4])),
          pd.DataFrame(data=[1, 2], index=pd.Index([3, 4])),
      )
      self.assert_eq(
          ps.DataFrame(data=data, index=pd.Index([1, 2, 3, 5, 6])),
          pd.DataFrame(data=data, index=pd.Index([1, 2, 3, 5, 6])),
      )
  
      # test local data with ps.Index
      self.assert_eq(
          ps.DataFrame(data=[1, 2], index=ps.Index([1, 2])),
          pd.DataFrame(data=[1, 2], index=pd.Index([1, 2])),
      )
      self.assert_eq(
          ps.DataFrame(data=[1, 2], index=ps.Index([2, 3])),
          pd.DataFrame(data=[1, 2], index=pd.Index([2, 3])),
      )
      self.assert_eq(
          ps.DataFrame(data=[1, 2], index=ps.Index([3, 4])),
          pd.DataFrame(data=[1, 2], index=pd.Index([3, 4])),
      )
      self.assert_eq(
          ps.DataFrame(data=data, index=ps.Index([1, 2, 3, 5, 6])),
          pd.DataFrame(data=data, index=pd.Index([1, 2, 3, 5, 6])),
      )
  
      err_msg = "Cannot combine the series or dataframe"
      with self.assertRaisesRegex(ValueError, err_msg):
          # test ps.DataFrame with ps.Index
          ps.DataFrame(
              data=ps.DataFrame([1, 2]), index=ps.Index([1, 2])
          )
      with self.assertRaisesRegex(ValueError, err_msg):
          # test ps.DataFrame with pd.Index
          ps.DataFrame(
              data=ps.DataFrame([1, 2]), index=pd.Index([3, 4])
          )
  
      with ps.option_context("compute.ops_on_diff_frames", True):
          # test pd.DataFrame with pd.Index
          self.assert_eq(
              ps.DataFrame(
                  data=pd.DataFrame([1, 2]), index=pd.Index([0, 1])
              ),
              pd.DataFrame(
                  data=pd.DataFrame([1, 2]), index=pd.Index([0, 1])
              ),
          )
          self.assert_eq(
              ps.DataFrame(
                  data=pd.DataFrame([1, 2]), index=pd.Index([1, 2])
              ),
              pd.DataFrame(
                  data=pd.DataFrame([1, 2]), index=pd.Index([1, 2])
              ),
          )
  
          # test ps.DataFrame with ps.Index
          self.assert_eq(
              ps.DataFrame(
                  data=ps.DataFrame([1, 2]), index=ps.Index([0, 1])
              ),
              pd.DataFrame(
                  data=pd.DataFrame([1, 2]), index=pd.Index([0, 1])
              ),
          )
          self.assert_eq(
              ps.DataFrame(
                  data=ps.DataFrame([1, 2]), index=ps.Index([1, 2])
              ),
              pd.DataFrame(
                  data=pd.DataFrame([1, 2]), index=pd.Index([1, 2])
              ),
          )
  
          # test ps.DataFrame with pd.Index
          self.assert_eq(
              ps.DataFrame(
                  data=ps.DataFrame([1, 2]), index=pd.Index([0, 1])
              ),
              pd.DataFrame(
                  data=pd.DataFrame([1, 2]), index=pd.Index([0, 1])
              ),
          )
          self.assert_eq(
              ps.DataFrame(
                  data=ps.DataFrame([1, 2]), index=pd.Index([1, 2])
              ),
              pd.DataFrame(
                  data=pd.DataFrame([1, 2]), index=pd.Index([1, 2])
              ),
          )
  
      # test with multi data columns
      pdf = pd.DataFrame(data=data, columns=["A", "B", "C"])
      psdf = ps.from_pandas(pdf)
  
      # test with pd.DataFrame and pd.Index
      self.assert_eq(
          ps.DataFrame(data=pdf, index=pd.Index([2, 3, 4, 5, 6])),
          pd.DataFrame(data=pdf, index=pd.Index([2, 3, 4, 5, 6])),
      )
  
      # test with pd.DataFrame and ps.Index
      self.assert_eq(
          ps.DataFrame(data=pdf, index=ps.Index([2, 3, 4, 5, 6])),
          pd.DataFrame(data=pdf, index=pd.Index([2, 3, 4, 5, 6])),
      )
  
      with ps.option_context("compute.ops_on_diff_frames", True):
          # test with ps.DataFrame and pd.Index
          self.assert_eq(
              ps.DataFrame(data=psdf, index=pd.Index([2, 3, 4, 5, 6])),
              pd.DataFrame(data=pdf, index=pd.Index([2, 3, 4, 5, 6])),
          )
  
          # test with ps.DataFrame and ps.Index
          self.assert_eq(
              ps.DataFrame(data=psdf, index=ps.Index([2, 3, 4, 5, 6])),
              pd.DataFrame(data=pdf, index=pd.Index([2, 3, 4, 5, 6])),
          )
  
      # test String Index
      pdf = pd.DataFrame(
          data={
              "s": ["Hello", "World", "Databricks"],
              "x": [2002, 2003, 2004],
          }
      )
      pdf = pdf.set_index("s")
      pdf.index.name = None
      psdf = ps.from_pandas(pdf)
  
      # test with pd.DataFrame and pd.Index
      self.assert_eq(
          ps.DataFrame(
              data=pdf,
              index=pd.Index(["Hello", "Universe", "Databricks"]),
          ),
          pd.DataFrame(
              data=pdf,
              index=pd.Index(["Hello", "Universe", "Databricks"]),
          ),
      )
  
      # test with pd.DataFrame and ps.Index
      self.assert_eq(
          ps.DataFrame(
              data=pdf,
              index=ps.Index(["Hello", "Universe", "Databricks"]),
          ),
          pd.DataFrame(
              data=pdf,
              index=pd.Index(["Hello", "Universe", "Databricks"]),
          ),
      )
  
      with ps.option_context("compute.ops_on_diff_frames", True):
          # test with ps.DataFrame and pd.Index
          self.assert_eq(
              ps.DataFrame(
                  data=psdf,
                  index=pd.Index(["Hello", "Universe", "Databricks"]),
              ).sort_index(),
              pd.DataFrame(
                  data=pdf,
                  index=pd.Index(["Hello", "Universe", "Databricks"]),
              ).sort_index(),
          )
  
          # test with ps.DataFrame and ps.Index
          self.assert_eq(
              ps.DataFrame(
                  data=psdf,
                  index=ps.Index(["Hello", "Universe", "Databricks"]),
              ).sort_index(),
              pd.DataFrame(
                  data=pdf,
                  index=pd.Index(["Hello", "Universe", "Databricks"]),
              ).sort_index(),
          )
  
      # test DatetimeIndex
      pdf = pd.DataFrame(
          data={
              "t": [
                  datetime(2022, 9, 1, 0, 0, 0, 0),
                  datetime(2022, 9, 2, 0, 0, 0, 0),
                  datetime(2022, 9, 3, 0, 0, 0, 0),
              ],
              "x": [2002, 2003, 2004],
          }
      )
      pdf = pdf.set_index("t")
      pdf.index.name = None
      psdf = ps.from_pandas(pdf)
  
      # test with pd.DataFrame and pd.DatetimeIndex
      self.assert_eq(
          ps.DataFrame(
              data=pdf,
              index=pd.DatetimeIndex(
                  [
                      "2022-08-31",
                      "2022-09-02",
                      "2022-09-03",
                      "2022-09-05",
                  ]
              ),
          ),
          pd.DataFrame(
              data=pdf,
              index=pd.DatetimeIndex(
                  [
                      "2022-08-31",
                      "2022-09-02",
                      "2022-09-03",
                      "2022-09-05",
                  ]
              ),
          ),
      )
  
      # test with pd.DataFrame and ps.DatetimeIndex
      self.assert_eq(
          ps.DataFrame(
              data=pdf,
              index=ps.DatetimeIndex(
                  [
                      "2022-08-31",
                      "2022-09-02",
                      "2022-09-03",
                      "2022-09-05",
                  ]
              ),
          ),
          pd.DataFrame(
              data=pdf,
              index=pd.DatetimeIndex(
                  [
                      "2022-08-31",
                      "2022-09-02",
                      "2022-09-03",
                      "2022-09-05",
                  ]
              ),
          ),
      )
  
      with ps.option_context("compute.ops_on_diff_frames", True):
          # test with ps.DataFrame and pd.DatetimeIndex
          self.assert_eq(
              ps.DataFrame(
                  data=psdf,
                  index=pd.DatetimeIndex(
                      [
                          "2022-08-31",
                          "2022-09-02",
                          "2022-09-03",
                          "2022-09-05",
                      ]
                  ),
              ),
              pd.DataFrame(
                  data=pdf,
                  index=pd.DatetimeIndex(
                      [
                          "2022-08-31",
                          "2022-09-02",
                          "2022-09-03",
                          "2022-09-05",
                      ]
                  ),
              ),
          )
  
          # test with ps.DataFrame and ps.DatetimeIndex
          self.assert_eq(
              ps.DataFrame(
                  data=psdf,
                  index=ps.DatetimeIndex(
                      [
                          "2022-08-31",
                          "2022-09-02",
                          "2022-09-03",
                          "2022-09-05",
                      ]
                  ),
              ),
              pd.DataFrame(
                  data=pdf,
                  index=pd.DatetimeIndex(
                      [
                          "2022-08-31",
                          "2022-09-02",
                          "2022-09-03",
                          "2022-09-05",
                      ]
                  ),
              ),
          )
  
      # test MultiIndex
      # test local data with ps.MultiIndex
      self.assert_eq(
          ps.DataFrame(
              data=[1, 2],
              index=ps.MultiIndex.from_tuples([(1, 3), (2, 4)]),
          ),
          pd.DataFrame(
              data=[1, 2],
              index=pd.MultiIndex.from_tuples([(1, 3), (2, 4)]),
          ),
      )
  
      # test distributed data with ps.MultiIndex
      err_msg = "Cannot combine a Distributed Dataset with a MultiIndex"
      with ps.option_context("compute.ops_on_diff_frames", True):
          with self.assertRaisesRegex(ValueError, err_msg):
              # test ps.DataFrame with ps.Index
              ps.DataFrame(
                  data=ps.DataFrame([1, 2]),
                  index=ps.MultiIndex.from_tuples([(1, 3), (2, 4)]),
              )
          with self.assertRaisesRegex(ValueError, err_msg):
              # test ps.DataFrame with pd.Index
              ps.DataFrame(
                  data=ps.DataFrame([1, 2]),
                  index=ps.MultiIndex.from_tuples([(1, 3), (2, 4)]),
              )
  
imports: from datetime import datetime, timedelta
  import unittest
  import numpy
  import pandas
  from pyspark import pandas
  from pyspark.pandas.typedef.typehints import extension_dtypes_available, extension_float_dtypes_available, extension_object_dtypes_available
  from pyspark.pandas.utils import is_testing
  from pyspark.testing.pandasutils import ComparisonTestBase
  from pyspark.testing.sqlutils import SQLTestUtils
label_desc: Use image node_id 4 for calling the FrameConstructorMixin obj's underlying member method code with example usage: obj.test_creation_index() without return types