From d48656bf32b4098808bd9493534ff29676cfd0b3 Mon Sep 17 00:00:00 2001 From: Herminio Vazquez Date: Sat, 6 Jul 2024 15:37:41 +0200 Subject: [PATCH] Feature polars one (#272) * Verification for new polars implementation * Added polars version into readme --- README.md | 2 +- cuallee/polars_validation.py | 2 +- pyproject.toml | 2 +- test/unit/polars_dataframe/test_has_mean.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ba841211..26ef1e25 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Provider | API | Versions ![bigquery](logos/bigquery.png?raw=true "BigQuery Client API")| `bigquery` | `3.4.1` ![pandas](logos/pandas.svg?raw=true "Pandas DataFrame API")| `pandas`| `2.0.2`, `1.5.x`, `1.4.x` ![duckdb](logos/duckdb.png?raw=true "DuckDB API")|`duckdb` | `0.10.2`,~~`0.9.2`~~,~~`0.8.0`~~, ~~`0.7.1`~~ -![polars](logos/polars.svg?raw=true "Polars API")|`polars`| `0.19.6` +![polars](logos/polars.svg?raw=true "Polars API")|`polars`| `1.0.0`,~~`0.19.6`~~ ![daft](logos/daft.png?raw=true "Daft API")|`daft`| `0.2.24`, ~~`0.2.19`~~ Logos are trademarks of their own brands. diff --git a/cuallee/polars_validation.py b/cuallee/polars_validation.py index f8cb0ff2..b50de0b1 100644 --- a/cuallee/polars_validation.py +++ b/cuallee/polars_validation.py @@ -113,7 +113,7 @@ def has_pattern(self, rule: Rule, dataframe: pl.DataFrame) -> Union[bool, int]: """Conformance on column values to regular expression threshold""" return Compute._result( dataframe.select( - operator.gt(pl.col(rule.column).str.count_match(rule.value), 0).cast( + operator.gt(pl.col(rule.column).str.count_matches(rule.value), 0).cast( pl.Int8 ) ) diff --git a/pyproject.toml b/pyproject.toml index 20c357d2..8862fb93 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,7 +48,7 @@ duckdb = [ "duckdb==1.0.0" ] polars = [ - "polars>=0.19.6" + "polars>=1.0.0" ] test = [ "pytest", diff --git a/test/unit/polars_dataframe/test_has_mean.py b/test/unit/polars_dataframe/test_has_mean.py index 02174824..8b79bde4 100644 --- a/test/unit/polars_dataframe/test_has_mean.py +++ b/test/unit/polars_dataframe/test_has_mean.py @@ -21,7 +21,7 @@ def test_negative(check: Check): @pytest.mark.parametrize("extra_value", [4, 4.0], ids=("int", "float")) def test_values(check: Check, extra_value): check.has_mean("id", extra_value) - df = pl.DataFrame({"id": [0, 1, 2, 3, 14] + [extra_value]}) + df = pl.DataFrame({"id": [0, 1, 2, 3, 14] + [extra_value]}, strict=False) result = check.validate(df).select(pl.col("status")) == "PASS" assert all(result.to_series().to_list())