Skip to content

Commit

Permalink
polars version update remaining (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
yusufuyanik1 authored Oct 2, 2023
1 parent 60f40cf commit 4ea247a
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions examples/articles/ADMExplained.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion examples/articles/thompsonsampling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion examples/graph_gallery/graph_gallery.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.0"
"version": "3.11.4"
},
"orig_nbformat": 4
},
Expand Down
6 changes: 3 additions & 3 deletions python/pdstools/adm/ADMTrees.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"),
]
)
Expand Down
4 changes: 2 additions & 2 deletions python/pdstools/utils/hds_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -461,7 +461,7 @@ def getHasher(
)

else:
return pl.col(cols).apply(algorithm)
return pl.col(cols).map_elements(algorithm)

def process(
self,
Expand Down
2 changes: 1 addition & 1 deletion python/pdstools/utils/hds_utils_experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [], []
Expand Down

0 comments on commit 4ea247a

Please sign in to comment.