code: def test_tail(self):
      pdf = pd.DataFrame(
          {
              "a": [1, 1, 1, 1, 2, 2, 2, 3, 3, 3] * 3,
              "b": [2, 3, 1, 4, 6, 9, 8, 10, 7, 5] * 3,
              "c": [3, 5, 2, 5, 1, 2, 6, 4, 3, 6] * 3,
          },
          index=np.random.rand(10 * 3),
      )
      psdf = ps.from_pandas(pdf)
  
      for limit in (2, 100000, -2, -100000, -1):
          self.assert_eq(
              pdf.groupby("a").tail(limit).sort_index(),
              psdf.groupby("a").tail(limit).sort_index(),
          )
          self.assert_eq(
              pdf.groupby("a")["b"].tail(limit).sort_index(),
              psdf.groupby("a")["b"].tail(limit).sort_index(),
          )
          self.assert_eq(
              pdf.groupby("a")[["b"]].tail(limit).sort_index(),
              psdf.groupby("a")[["b"]].tail(limit).sort_index(),
          )
  
      self.assert_eq(
          pdf.groupby(pdf.a // 2).tail(2).sort_index(),
          psdf.groupby(psdf.a // 2).tail(2).sort_index(),
      )
      self.assert_eq(
          pdf.groupby(pdf.a // 2)["b"].tail(2).sort_index(),
          psdf.groupby(psdf.a // 2)["b"].tail(2).sort_index(),
      )
      self.assert_eq(
          pdf.groupby(pdf.a // 2)[["b"]].tail(2).sort_index(),
          psdf.groupby(psdf.a // 2)[["b"]].tail(2).sort_index(),
      )
  
      self.assert_eq(
          pdf.b.rename().groupby(pdf.a).tail(2).sort_index(),
          psdf.b.rename().groupby(psdf.a).tail(2).sort_index(),
      )
      self.assert_eq(
          pdf.b.groupby(pdf.a.rename()).tail(2).sort_index(),
          psdf.b.groupby(psdf.a.rename()).tail(2).sort_index(),
      )
      self.assert_eq(
          pdf.b.rename().groupby(pdf.a.rename()).tail(2).sort_index(),
          psdf.b.rename().groupby(psdf.a.rename()).tail(2).sort_index(),
      )
  
      # multi-index
      midx = pd.MultiIndex(
          [
              ["x", "y"],
              ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"],
          ],
          [
              [0, 0, 0, 0, 0, 1, 1, 1, 1, 1],
              [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
          ],
      )
      pdf = pd.DataFrame(
          {
              "a": [1, 1, 1, 1, 2, 2, 2, 3, 3, 3],
              "b": [2, 3, 1, 4, 6, 9, 8, 10, 7, 5],
              "c": [3, 5, 2, 5, 1, 2, 6, 4, 3, 6],
          },
          columns=["a", "b", "c"],
          index=midx,
      )
      psdf = ps.from_pandas(pdf)
  
      for limit in (2, 100000, -2, -100000, -1):
          self.assert_eq(
              pdf.groupby("a").tail(limit).sort_index(),
              psdf.groupby("a").tail(limit).sort_index(),
          )
          self.assert_eq(
              pdf.groupby("a")["b"].tail(limit).sort_index(),
              psdf.groupby("a")["b"].tail(limit).sort_index(),
          )
  
      # multi-index columns
      columns = pd.MultiIndex.from_tuples(
          [("x", "a"), ("x", "b"), ("y", "c")]
      )
      pdf.columns = columns
      psdf.columns = columns
  
      for limit in (2, 100000, -2, -100000, -1):
          self.assert_eq(
              pdf.groupby(("x", "a")).tail(limit).sort_index(),
              psdf.groupby(("x", "a")).tail(limit).sort_index(),
          )
  
file_path: spark/python/pyspark/pandas/tests/groupby/test_head_tail.py
imports: import unittest
  import numpy
  import pandas
  from pyspark import pandas
  from pyspark.testing.pandasutils import ComparisonTestBase
  from pyspark.testing.sqlutils import SQLTestUtils
label_desc: Use image node_id 2 for calling the GroupbyHeadTailMixin obj's underlying member method code with example usage: obj.test_tail() without return types