code: def test_groupby_apply(self):
      pdf, psdf = self.df_pair
  
      self.assert_eq(
          psdf.groupby("a").apply(lambda df: df).sort_index(),
          pdf.groupby("a").apply(lambda df: df).sort_index(),
      )
      self.assert_eq(
          psdf.groupby("b").apply(lambda df: df[["a"]]).sort_index(),
          pdf.groupby("b").apply(lambda df: df[["a"]]).sort_index(),
      )
      self.assert_eq(
          psdf.groupby(["a", "b"]).apply(lambda df: df).sort_index(),
          pdf.groupby(["a", "b"]).apply(lambda df: df).sort_index(),
      )
      self.assert_eq(
          psdf.groupby("a")
          .apply(lambda df: df.b.cat.codes)
          .sort_index(),
          pdf.groupby("a")
          .apply(lambda df: df.b.cat.codes)
          .sort_index(),
      )
      self.assert_eq(
          psdf.groupby("a")["b"]
          .apply(lambda b: b.cat.codes)
          .sort_index(),
          pdf.groupby("a")["b"]
          .apply(lambda b: b.cat.codes)
          .sort_index(),
      )
  
imports: import numpy
  import pandas
  from pandas.api.types import CategoricalDtype
  import pyspark.pandas
  from pyspark.testing.pandasutils import ComparisonTestBase, TestUtils
label_desc: Use image node_id 19 for calling the CategoricalTestsMixin obj's underlying member method code with example usage: obj.test_groupby_apply() without return types