From 4ea247a17cebde7156fdfb0ebdd179e9592de5cc Mon Sep 17 00:00:00 2001 From: yusufuyanik1 <54443450+yusufuyanik1@users.noreply.github.com> Date: Mon, 2 Oct 2023 10:07:14 +0200 Subject: [PATCH] polars version update remaining (#126) --- examples/articles/ADMExplained.ipynb | 4 ++-- examples/articles/thompsonsampling.ipynb | 2 +- examples/graph_gallery/graph_gallery.ipynb | 2 +- python/pdstools/adm/ADMTrees.py | 6 +++--- python/pdstools/utils/hds_utils.py | 4 ++-- python/pdstools/utils/hds_utils_experimental.py | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/articles/ADMExplained.ipynb b/examples/articles/ADMExplained.ipynb index 45413acf..c3d05586 100644 --- a/examples/articles/ADMExplained.ipynb +++ b/examples/articles/ADMExplained.ipynb @@ -641,12 +641,12 @@ " pl.col(\"Contents\").cast(pl.Utf8)\n", " ).with_columns(\n", " pl.when(pl.col(\"Type\") == \"numeric\")\n", - " .then(pl.col(\"Contents\").apply(lambda col: extract_numbers_in_contents(col, 0)))\n", + " .then(pl.col(\"Contents\").map_elements(lambda col: extract_numbers_in_contents(col, 0)))\n", " .otherwise(pl.lit(-9999))\n", " .alias(\"BinLowerBound\")\n", " .cast(pl.Float32),\n", " pl.when(pl.col(\"Type\") == \"numeric\")\n", - " .then(pl.col(\"Contents\").apply(lambda col: extract_numbers_in_contents(col, 1)))\n", + " .then(pl.col(\"Contents\").map_elements(lambda col: extract_numbers_in_contents(col, 1)))\n", " .otherwise(pl.lit(-9999))\n", " .alias(\"BinUpperBound\")\n", " .cast(pl.Float32),\n", diff --git a/examples/articles/thompsonsampling.ipynb b/examples/articles/thompsonsampling.ipynb index 4a526a5c..474958f2 100644 --- a/examples/articles/thompsonsampling.ipynb +++ b/examples/articles/thompsonsampling.ipynb @@ -49,7 +49,7 @@ ").explode(\"p\").with_columns(evidence=pl.col(\"positives\") / pl.col(\"p\"))\n", "\n", "def betaDistribution(structcol):\n", - " return structcol.apply(\n", + " return structcol.map_elements(\n", " lambda x: np.random.beta(\n", " x[\"p\"] * x[\"evidence\"], (1 - x[\"p\"]) * x[\"evidence\"], x[\"n\"]\n", " ).tolist()\n", diff --git a/examples/graph_gallery/graph_gallery.ipynb b/examples/graph_gallery/graph_gallery.ipynb index 5ff95639..849e72d8 100644 --- a/examples/graph_gallery/graph_gallery.ipynb +++ b/examples/graph_gallery/graph_gallery.ipynb @@ -256,7 +256,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.0" + "version": "3.11.4" }, "orig_nbformat": 4 }, diff --git a/python/pdstools/adm/ADMTrees.py b/python/pdstools/adm/ADMTrees.py index a816f864..782e867d 100644 --- a/python/pdstools/adm/ADMTrees.py +++ b/python/pdstools/adm/ADMTrees.py @@ -473,7 +473,7 @@ def getGainsPerSplit(self) -> Tuple[Dict, pl.DataFrame, dict]: list(zip(total_split_list, total_gains_list)), schema=["split", "gains"] ) gainsPerSplit = gainsPerSplit.with_columns( - predictor=pl.col("split").apply(lambda x: self.parseSplitValues(x)[0]) + predictor=pl.col("split").map_elements(lambda x: self.parseSplitValues(x)[0]) ) return splitsPerTree, gainsPerTree, gainsPerSplit @@ -491,10 +491,10 @@ def getGroupedGainsPerSplit(self) -> pl.DataFrame: pl.col("gains").implode(), pl.col("gains").mean().alias("mean"), pl.first("split") - .apply(lambda x: self.parseSplitValues(x)[1]) + .map_elements(lambda x: self.parseSplitValues(x)[1]) .alias("sign"), pl.first("split") - .apply(lambda x: self.parseSplitValues(x)[2]) + .map_elements(lambda x: self.parseSplitValues(x)[2]) .alias("values"), ] ) diff --git a/python/pdstools/utils/hds_utils.py b/python/pdstools/utils/hds_utils.py index 04a8924c..8f2d4141 100644 --- a/python/pdstools/utils/hds_utils.py +++ b/python/pdstools/utils/hds_utils.py @@ -300,7 +300,7 @@ def sample_it(s: pl.Series) -> pl.Series: df_ = ( df.lazy() - .with_columns(pl.first().map(sample_it).alias("_sample")) + .with_columns(pl.first().map_batches(sample_it).alias("_sample")) .filter(pl.col("_sample")) .drop("_sample") .collect() @@ -461,7 +461,7 @@ def getHasher( ) else: - return pl.col(cols).apply(algorithm) + return pl.col(cols).map_elements(algorithm) def process( self, diff --git a/python/pdstools/utils/hds_utils_experimental.py b/python/pdstools/utils/hds_utils_experimental.py index 4e39d192..7b95267a 100644 --- a/python/pdstools/utils/hds_utils_experimental.py +++ b/python/pdstools/utils/hds_utils_experimental.py @@ -493,7 +493,7 @@ def getHasher( return pl.col(cols).hash(**self.seeds) else: - return pl.col(cols).apply(algorithm) + return pl.col(cols).map_elements(algorithm) def to_normalize(self, cols, verbose=False): self.normalizationFailures, exprs = [], []