Skip to content

Commit

Permalink
python polars 0.10.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Oct 15, 2021
1 parent 47ad9b5 commit 0599f60
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

changelog-python:
docker run -it --env-file .env --rm -v "$(pwd)":/usr/local/src/your-app githubchangeloggenerator/github-changelog-generator -u pola-rs -p project --exclude-labels rust
docker run -it --env-file .env --rm -v "$(pwd)":/usr/local/src/your-app githubchangeloggenerator/github-changelog-generator -u pola-rs -p polars --exclude-labels rust

changelog-rust:
docker run -it --env-file .env --rm -v "$(pwd)":/usr/local/src/your-app githubchangeloggenerator/github-changelog-generator -u pola-rs -p project --exclude-labels python
docker run -it --env-file .env --rm -v "$(pwd)":/usr/local/src/your-app githubchangeloggenerator/github-changelog-generator -u pola-rs -p polars --exclude-labels python
2 changes: 1 addition & 1 deletion py-polars/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion py-polars/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "py-polars"
version = "0.10.3"
version = "0.10.4"
authors = ["ritchie46 <ritchie46@gmail.com>"]
edition = "2018"
readme = "README.md"
Expand Down
2 changes: 2 additions & 0 deletions py-polars/polars/eager/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,8 @@ def __getitem__(self, item: Any) -> Any:
return NotImplemented
out = f(item)
if self.dtype == List:
if out is None:
return None
return wrap_s(out)
return out

Expand Down
5 changes: 5 additions & 0 deletions py-polars/src/lazy/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ pub fn map_mul(
// this is a python Series
let out = call_lambda_with_series_slice(py, s, &lambda, &pypolars);

// we return an error, because that will become a null value polars lazy apply list
if apply_groups && out.is_none(py) {
return Err(PolarsError::NoData("".into()))
}

// unpack the wrapper in a PySeries
let py_pyseries = out.getattr(py, "_s").expect(
"Could net get series attribute '_s'. \
Expand Down
16 changes: 16 additions & 0 deletions py-polars/tests/test_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,19 @@ def test_apply_none():

out = df.select(pl.map(exprs=["a", "b"], f=lambda s: s[0] * s[1]))
assert out["a"].to_list() == (df["a"] * df["b"]).to_list()

# check if we can return None
def func(s):
if s[0][0] == 190:
return None
else:
return s[0]

out = (
df.groupby("g", maintain_order=True).agg(
pl.apply(exprs=["a", pl.col("b") ** 4, pl.col("a") / 4], f=func).alias(
"multiple"
)
)
)["multiple"]
assert out[1] is None

0 comments on commit 0599f60

Please sign in to comment.