From 5bf20b244452aed640bef473d818713a9048c6a1 Mon Sep 17 00:00:00 2001 From: Yaser Martinez Palenzuela Date: Sun, 8 Sep 2024 22:19:21 +0200 Subject: [PATCH 1/3] Fix polars_col_stats.py Fix error when tracking with polars dataframes: ``` return col.str.lengths() ^^^^^^^^^^^^^^^ AttributeError: 'StringNameSpace' object has no attribute 'lengths' ``` --- ui/sdk/src/hamilton_sdk/tracking/polars_col_stats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/sdk/src/hamilton_sdk/tracking/polars_col_stats.py b/ui/sdk/src/hamilton_sdk/tracking/polars_col_stats.py index bb7e43232..cc2f74dd3 100644 --- a/ui/sdk/src/hamilton_sdk/tracking/polars_col_stats.py +++ b/ui/sdk/src/hamilton_sdk/tracking/polars_col_stats.py @@ -147,7 +147,7 @@ def datetime_column_stats( def str_len(col: pl.Series) -> pl.Series: - return col.str.lengths() + return col.str.len_chars() def avg_str_len(str_len: pl.Series) -> float: From 9424fd1cfdbd882b0798e9e9c6d3b27ad5380d08 Mon Sep 17 00:00:00 2001 From: Yaser Martinez Palenzuela Date: Tue, 10 Sep 2024 17:41:38 +0000 Subject: [PATCH 2/3] add test for hamilton_sdk.tracking.polars_col_stats.str_len --- ui/sdk/tests/tracking/test_polars_col_stats.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/sdk/tests/tracking/test_polars_col_stats.py b/ui/sdk/tests/tracking/test_polars_col_stats.py index 05a54d85a..835dc609b 100644 --- a/ui/sdk/tests/tracking/test_polars_col_stats.py +++ b/ui/sdk/tests/tracking/test_polars_col_stats.py @@ -108,3 +108,6 @@ def test_min_string(example_df_string): def test_max_string(example_df_string): assert pcs.max(example_df_string["a"]) == "e" + +def test_str_len(example_df_string): + assert pcs.str_len(example_df_string["a"]).to_list() == [1, 1, 1, 1, 1] \ No newline at end of file From 3cb0706339b1e6c2fef0d4847e2652d3415d6842 Mon Sep 17 00:00:00 2001 From: Yaser Martinez Palenzuela Date: Tue, 10 Sep 2024 19:20:46 +0000 Subject: [PATCH 3/3] pre-commit cleanups --- ui/sdk/tests/tracking/test_polars_col_stats.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/sdk/tests/tracking/test_polars_col_stats.py b/ui/sdk/tests/tracking/test_polars_col_stats.py index 835dc609b..a20e79385 100644 --- a/ui/sdk/tests/tracking/test_polars_col_stats.py +++ b/ui/sdk/tests/tracking/test_polars_col_stats.py @@ -109,5 +109,6 @@ def test_min_string(example_df_string): def test_max_string(example_df_string): assert pcs.max(example_df_string["a"]) == "e" + def test_str_len(example_df_string): - assert pcs.str_len(example_df_string["a"]).to_list() == [1, 1, 1, 1, 1] \ No newline at end of file + assert pcs.str_len(example_df_string["a"]).to_list() == [1, 1, 1, 1, 1]