code: def test_pivot_table_firstlast(values, aggfunc):
      df = pd.DataFrame(
          {
              "A": np.random.choice(list("XYZ"), size=100),
              "B": np.random.randn(100),
              "C": pd.Categorical(
                  np.random.choice(list("abc"), size=100)
              ),
              "D": np.random.choice(list("abc"), size=100),
          }
      )
      ddf = dd.from_pandas(df, 5).repartition(
          (0, 20, 40, 60, 80, 98, 99)
      )
  
      res = dd.pivot_table(
          ddf, index="A", columns="C", values=values, aggfunc=aggfunc
      )
      exp = pd.pivot_table(
          df,
          index="A",
          columns="C",
          values=values,
          aggfunc=aggfunc,
          observed=False,
      )
  
      assert_eq(exp, res)
  
      # method
      res = ddf.pivot_table(
          index="A", columns="C", values=values, aggfunc=aggfunc
      )
      exp = df.pivot_table(
          index="A",
          columns="C",
          values=values,
          aggfunc=aggfunc,
          observed=False,
      )
  
      assert_eq(exp, res)
  
imports: from __future__ import annotations
  import contextlib
  import warnings
  import numpy
  import pandas
  import pytest
  from packaging.version import parse
  import dask.dataframe
  from dask.dataframe._compat import PANDAS_VERSION, tm
  from dask.dataframe.reshape import _get_dummies_dtype_default
  from dask.dataframe.utils import assert_eq, make_meta
label_desc: Use image node_id 12 for calling a global function with example usage: test_pivot_table_firstlast(values, aggfunc) without return types