From 82fcb74c225fba2c187ea2511622326498f2588c Mon Sep 17 00:00:00 2001 From: Weijie Guo Date: Sun, 20 Aug 2023 19:27:16 +0800 Subject: [PATCH 1/4] feat(rust, python): supports cast to list --- Cargo.toml | 2 +- py-polars/tests/unit/datatypes/test_list.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index da68e35af692..11d32f4e32a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,7 +54,7 @@ xxhash-rust = { version = "0.8.6", features = ["xxh3"] } [workspace.dependencies.arrow] package = "arrow2" git = "https://github.com/jorgecarleitao/arrow2" -rev = "2b3e2a9e83725a557d78b90cd39298c5bef0ca4a" +rev = "3d7d9acdda34f36d904e362de411792714794331" # branch = "" # version = "0.17.4" default-features = false diff --git a/py-polars/tests/unit/datatypes/test_list.py b/py-polars/tests/unit/datatypes/test_list.py index 70f2117caad4..443eb4d1e5ac 100644 --- a/py-polars/tests/unit/datatypes/test_list.py +++ b/py-polars/tests/unit/datatypes/test_list.py @@ -439,6 +439,14 @@ def test_list_recursive_categorical_cast() -> None: assert s.to_list() == values +def test_non_nested_cast_to_list() -> None: + df = pl.DataFrame({"a": [1, 2, 3]}) + + df = df.with_columns([pl.col("a").cast(pl.List(pl.Int64))]) + + assert df.to_dict(False) == {"a": [[1], [2], [3]]} + + def test_list_new_from_index_logical() -> None: s = ( pl.select(pl.struct(pl.Series("a", [date(2001, 1, 1)])).implode()) From 0e61903a96468827362c64f259031c0c2e092898 Mon Sep 17 00:00:00 2001 From: Weijie Guo Date: Mon, 21 Aug 2023 15:44:08 +0800 Subject: [PATCH 2/4] Use fixed commit --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 11d32f4e32a6..0ec7f425cce6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,7 +54,7 @@ xxhash-rust = { version = "0.8.6", features = ["xxh3"] } [workspace.dependencies.arrow] package = "arrow2" git = "https://github.com/jorgecarleitao/arrow2" -rev = "3d7d9acdda34f36d904e362de411792714794331" +rev = "ba6a882bc1542b0b899774b696ebea77482b5c31" # branch = "" # version = "0.17.4" default-features = false From 9e4a861bfd4e0603ae0deb307ae8d5c4b40ec354 Mon Sep 17 00:00:00 2001 From: Weijie Guo Date: Mon, 21 Aug 2023 18:38:00 +0800 Subject: [PATCH 3/4] Re-trigger CI From 6e76cae9b370cd229fd04e7fa4eb16eaaf648dc9 Mon Sep 17 00:00:00 2001 From: Weijie Guo Date: Tue, 22 Aug 2023 02:24:26 +0800 Subject: [PATCH 4/4] assert series equal --- py-polars/tests/unit/datatypes/test_list.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/py-polars/tests/unit/datatypes/test_list.py b/py-polars/tests/unit/datatypes/test_list.py index 443eb4d1e5ac..53901bab76a1 100644 --- a/py-polars/tests/unit/datatypes/test_list.py +++ b/py-polars/tests/unit/datatypes/test_list.py @@ -5,6 +5,7 @@ import pandas as pd import polars as pl +from polars.testing import assert_series_equal def test_dtype() -> None: @@ -444,7 +445,8 @@ def test_non_nested_cast_to_list() -> None: df = df.with_columns([pl.col("a").cast(pl.List(pl.Int64))]) - assert df.to_dict(False) == {"a": [[1], [2], [3]]} + expected = pl.Series("a", [[1], [2], [3]]) + assert_series_equal(df.to_series(), expected) def test_list_new_from_index_logical() -> None: