code: def test_repartition(self):
      psdf = ps.DataFrame(
          {
              "age": [5, 5, 2, 2],
              "name": ["Bob", "Bob", "Alice", "Alice"],
          }
      )
      num_partitions = psdf.to_spark().rdd.getNumPartitions() + 1
  
      num_partitions += 1
      new_psdf = psdf.spark.repartition(num_partitions)
      self.assertEqual(
          new_psdf.to_spark().rdd.getNumPartitions(), num_partitions
      )
      self.assert_eq(psdf.sort_index(), new_psdf.sort_index())
  
      # Reserves Index
      psdf = psdf.set_index("age")
      num_partitions += 1
      new_psdf = psdf.spark.repartition(num_partitions)
      self.assertEqual(
          new_psdf.to_spark().rdd.getNumPartitions(), num_partitions
      )
      self.assert_eq(psdf.sort_index(), new_psdf.sort_index())
  
      # Reflects internal changes
      psdf = psdf.reset_index()
      psdf = psdf.set_index("name")
      psdf2 = psdf + 1
      num_partitions += 1
      self.assert_eq(
          psdf2.sort_index(),
          (psdf + 1).spark.repartition(num_partitions).sort_index(),
      )
  
      # Reserves MultiIndex
      psdf = ps.DataFrame(
          {"a": ["a", "b", "c"]}, index=[[1, 2, 3], [4, 5, 6]]
      )
      num_partitions = psdf.to_spark().rdd.getNumPartitions() + 1
      new_psdf = psdf.spark.repartition(num_partitions)
      self.assertEqual(
          new_psdf.to_spark().rdd.getNumPartitions(), num_partitions
      )
      self.assert_eq(psdf.sort_index(), new_psdf.sort_index())
  
file_path: spark/python/pyspark/pandas/tests/test_frame_spark.py
imports: import os
  import pandas
  from pyspark import pandas
  from pyspark.testing.pandasutils import PandasOnSparkTestCase, TestUtils
  from pyspark.testing.sqlutils import SQLTestUtils
label_desc: Use image node_id 3 for calling the SparkFrameMethodsTestsMixin obj's underlying member method code with example usage: obj.test_repartition() without return types