code: def test_categorical_vs_str_group_by() -> None:
      # this triggers the perfect hash table
      s = pl.Series("a", np.random.randint(0, 50, 100))
      s_with_nulls = pl.select(
          pl.when(s < 3).then(None).otherwise(s).alias("a")
      ).to_series()
  
      for s_ in [s, s_with_nulls]:
          s_ = s_.cast(str)
          cat_out = (
              s_.cast(pl.Categorical)
              .to_frame("a")
              .group_by("a")
              .agg(pl.first().alias("first"))
          )
  
          str_out = (
              s_.to_frame("a")
              .group_by("a")
              .agg(pl.first().alias("first"))
          )
          cat_out.with_columns(pl.col("a").cast(str))
          assert_frame_equal(
              cat_out.with_columns(
                  pl.col("a").cast(str),
                  pl.col("first").cast(pl.List(str)),
              ).sort("a"),
              str_out.sort("a"),
          )
  
file_path: polars/py-polars/tests/benchmark/test_release.py
imports: import time
  from pathlib import Path
  from typing import cast
  import numpy
  import pytest
  import polars
  from polars.testing import assert_frame_equal
label_desc: Use image node_id 10 for calling a global function with example usage: test_categorical_vs_str_group_by() without return types