Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polars version update remaining #126

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading