Path: blob/main/py-polars/tests/unit/streaming/test_streaming_categoricals.py
6939 views
import pytest12import polars as pl34pytestmark = pytest.mark.xdist_group("streaming")567def test_streaming_nested_categorical() -> None:8assert (9pl.LazyFrame({"numbers": [1, 1, 2], "cat": [["str"], ["foo"], ["bar"]]})10.with_columns(pl.col("cat").cast(pl.List(pl.Categorical)))11.group_by("numbers")12.agg(pl.col("cat").first())13.sort("numbers")14).collect(engine="streaming").to_dict(as_series=False) == {15"numbers": [1, 2],16"cat": [["str"], ["bar"]],17}181920def test_streaming_cat_14933() -> None:21# https://github.com/pola-rs/polars/issues/149332223df1 = pl.LazyFrame({"a": pl.Series([0], dtype=pl.UInt32)})24df2 = pl.LazyFrame(25[26pl.Series("a", [0, 1], dtype=pl.UInt32),27pl.Series("l", [None, None], dtype=pl.Categorical()),28]29)30result = df1.join(df2, on="a", how="left")31expected = {"a": [0], "l": [None]}32assert result.collect(engine="streaming").to_dict(as_series=False) == expected333435