code: def test_apply(self):
      pdf = pd.DataFrame(
          {
              "a": [1, 2, 3, 4, 5, 6],
              "b": [1, 1, 2, 3, 5, 8],
              "c": [1, 4, 9, 16, 25, 36],
          },
          columns=["a", "b", "c"],
      )
      psdf = ps.from_pandas(pdf)
      self.assert_eq(
          psdf.groupby("b").apply(lambda x: x + x.min()).sort_index(),
          pdf.groupby("b").apply(lambda x: x + x.min()).sort_index(),
      )
      self.assert_eq(
          psdf.groupby("b").apply(len).sort_index(),
          pdf.groupby("b").apply(len).sort_index(),
      )
      self.assert_eq(
          psdf.groupby("b")["a"]
          .apply(lambda x, y, z: x + x.min() + y * z, 10, z=20)
          .sort_index(),
          pdf.groupby("b")["a"]
          .apply(lambda x, y, z: x + x.min() + y * z, 10, z=20)
          .sort_index(),
      )
      self.assert_eq(
          psdf.groupby("b")[["a"]]
          .apply(lambda x: x + x.min())
          .sort_index(),
          pdf.groupby("b")[["a"]]
          .apply(lambda x: x + x.min())
          .sort_index(),
      )
      self.assert_eq(
          psdf.groupby(["a", "b"])
          .apply(lambda x, y, z: x + x.min() + y + z, 1, z=2)
          .sort_index(),
          pdf.groupby(["a", "b"])
          .apply(lambda x, y, z: x + x.min() + y + z, 1, z=2)
          .sort_index(),
      )
      self.assert_eq(
          psdf.groupby(["b"])["c"].apply(lambda x: 1).sort_index(),
          pdf.groupby(["b"])["c"].apply(lambda x: 1).sort_index(),
      )
      self.assert_eq(
          psdf.groupby(["b"])["c"].apply(len).sort_index(),
          pdf.groupby(["b"])["c"].apply(len).sort_index(),
      )
      self.assert_eq(
          psdf.groupby(psdf.b // 5)
          .apply(lambda x: x + x.min())
          .sort_index(),
          pdf.groupby(pdf.b // 5)
          .apply(lambda x: x + x.min())
          .sort_index(),
          almost=True,
      )
      self.assert_eq(
          psdf.groupby(psdf.b // 5)["a"]
          .apply(lambda x: x + x.min())
          .sort_index(),
          pdf.groupby(pdf.b // 5)["a"]
          .apply(lambda x: x + x.min())
          .sort_index(),
          almost=True,
      )
      self.assert_eq(
          psdf.groupby(psdf.b // 5)[["a"]]
          .apply(lambda x: x + x.min())
          .sort_index(),
          pdf.groupby(pdf.b // 5)[["a"]]
          .apply(lambda x: x + x.min())
          .sort_index(),
          almost=True,
      )
      self.assert_eq(
          psdf.groupby(psdf.b // 5)[["a"]].apply(len).sort_index(),
          pdf.groupby(pdf.b // 5)[["a"]].apply(len).sort_index(),
          almost=True,
      )
      self.assert_eq(
          psdf.a.rename()
          .groupby(psdf.b)
          .apply(lambda x: x + x.min())
          .sort_index(),
          pdf.a.rename()
          .groupby(pdf.b)
          .apply(lambda x: x + x.min())
          .sort_index(),
      )
      self.assert_eq(
          psdf.a.groupby(psdf.b.rename())
          .apply(lambda x: x + x.min())
          .sort_index(),
          pdf.a.groupby(pdf.b.rename())
          .apply(lambda x: x + x.min())
          .sort_index(),
      )
      self.assert_eq(
          psdf.a.rename()
          .groupby(psdf.b.rename())
          .apply(lambda x: x + x.min())
          .sort_index(),
          pdf.a.rename()
          .groupby(pdf.b.rename())
          .apply(lambda x: x + x.min())
          .sort_index(),
      )
  
      with self.assertRaisesRegex(
          TypeError, "int object is not callable"
      ):
          psdf.groupby("b").apply(1)
  
      # multi-index columns
      columns = pd.MultiIndex.from_tuples(
          [("x", "a"), ("x", "b"), ("y", "c")]
      )
      pdf.columns = columns
      psdf.columns = columns
  
      self.assert_eq(
          psdf.groupby(("x", "b")).apply(lambda x: 1).sort_index(),
          pdf.groupby(("x", "b")).apply(lambda x: 1).sort_index(),
      )
      self.assert_eq(
          psdf.groupby([("x", "a"), ("x", "b")])
          .apply(lambda x: x + x.min())
          .sort_index(),
          pdf.groupby([("x", "a"), ("x", "b")])
          .apply(lambda x: x + x.min())
          .sort_index(),
      )
      self.assert_eq(
          psdf.groupby(("x", "b")).apply(len).sort_index(),
          pdf.groupby(("x", "b")).apply(len).sort_index(),
      )
      self.assert_eq(
          psdf.groupby([("x", "a"), ("x", "b")])
          .apply(len)
          .sort_index(),
          pdf.groupby([("x", "a"), ("x", "b")]).apply(len).sort_index(),
      )
  
imports: import unittest
  import numpy
  import pandas
  from pyspark import pandas
  from pyspark.pandas.config import option_context
  from pyspark.testing.pandasutils import ComparisonTestBase
  from pyspark.testing.sqlutils import SQLTestUtils
label_desc: Use image node_id 1 for calling the GroupbyApplyFuncMixin obj's underlying member method code with example usage: obj.test_apply() without return types