code: def test_categorical() -> None:
      # https://github.com/pola-rs/polars/issues/2038
      df = pl.DataFrame(
          [
              pl.Series("a", [1, 1, 1, 1, 1, 1, 1, 1]),
              pl.Series("b", [8, 2, 3, 6, 3, 6, 2, 2]),
              pl.Series(
                  "c", ["a", "b", "c", "a", "b", "c", "a", "b"]
              ).cast(pl.Categorical),
          ]
      )
      out = (
          df.group_by(["a", "b"])
          .agg(
              pl.col("c").count().alias("num_different_c"),
              pl.col("c").alias("c_values"),
          )
          .filter(pl.col("num_different_c") >= 2)
          .to_series(3)
      )
  
      assert out.dtype.inner == pl.Categorical  # type: ignore[attr-defined]
      assert out.dtype.inner.is_nested() is False
  
imports: from __future__ import annotations
  import pickle
  from datetime import date, datetime, time
  from typing import TYPE_CHECKING, Any
  import pandas
  import pytest
  import polars
  from polars.testing import assert_frame_equal, assert_series_equal
label_desc: Use image node_id 2 for calling a global function with example usage: test_categorical() without return types