code: def test_array_in_group_by() -> None:
      df = pl.DataFrame(
          [
              pl.Series("id", [1, 2]),
              pl.Series(
                  "list", [[1, 2], [5, 5]], dtype=pl.Array(pl.UInt8, 2)
              ),
          ]
      )
  
      assert next(iter(df.group_by("id", maintain_order=True)))[1][
          "list"
      ].to_list() == [[1, 2]]
  
      df = pl.DataFrame(
          {"a": [[1, 2], [2, 2], [1, 4]], "g": [1, 1, 2]},
          schema={"a": pl.Array(pl.Int64, 2), "g": pl.Int64},
      )
  
      out0 = df.group_by("g").agg(pl.col("a")).sort("g")
      out1 = df.set_sorted("g").group_by("g").agg(pl.col("a"))
  
      for out in [out0, out1]:
          assert out.schema == {
              "g": pl.Int64,
              "a": pl.List(pl.Array(pl.Int64, 2)),
          }
          assert out.to_dict(as_series=False) == {
              "g": [1, 2],
              "a": [[[1, 2], [2, 2]], [[1, 4]]],
          }
  
file_path: polars/py-polars/tests/unit/datatypes/test_array.py
imports: import datetime
  from typing import Any
  import pytest
  import polars
  from polars.exceptions import InvalidOperationError
  from polars.testing import assert_series_equal
label_desc: Use image node_id 3 for calling a global function with example usage: test_array_in_group_by() without return types