Skip to content

Commit

Permalink
python polars: 0.13.59 (#4198)
Browse files Browse the repository at this point in the history
* python: pl.all()/pl.any() accept expr

* python polars: 0.13.59
  • Loading branch information
ritchie46 committed Aug 1, 2022
1 parent 7d6ba8d commit 8f686b1
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/create-py-mac-universal2-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
with:
maturin-version: '0.13.0'
command: publish
args: -m py-polars/Cargo.toml --no-default-features --features=all --target aarch64-apple-darwin --no-sdist -o wheels -i python -u ritchie46
args: -m py-polars/Cargo.toml --target aarch64-apple-darwin --no-sdist -o wheels -i python -u ritchie46
# uncomment to build a universal2 wheel
# we don't run it because it is twice as big and not needed because we build
# for both architectures separately
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create-py-release-manylinux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
target: aarch64-unknown-linux-gnu
maturin-version: '0.13.0'
command: publish
args: -m py-polars/Cargo.toml --no-default-features --features=all --no-sdist -o wheels -i python -u ritchie46
args: -m py-polars/Cargo.toml --no-sdist -o wheels -i python -u ritchie46
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.13.58"
version = "0.13.59"
authors = ["ritchie46 <ritchie46@gmail.com>"]
documentation = "https://pola-rs.github.io/polars/py-polars/html/reference/index.html"
edition = "2021"
Expand Down
8 changes: 4 additions & 4 deletions py-polars/polars/internals/lazy_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,9 +871,9 @@ def fold(
return pli.wrap_expr(pyfold(acc._pyexpr, f, exprs))


def any(name: str | list[pli.Expr]) -> pli.Expr:
def any(name: str | list[pli.Expr] | pli.Expr) -> pli.Expr:
"""Evaluate columnwise or elementwise with a bitwise OR operation."""
if isinstance(name, list):
if isinstance(name, (list, pli.Expr)):
return fold(lit(False), lambda a, b: a.cast(bool) | b.cast(bool), name).alias(
"any"
)
Expand Down Expand Up @@ -982,7 +982,7 @@ def exclude(
return col("*").exclude(columns)


def all(name: str | list[pli.Expr] | None = None) -> pli.Expr:
def all(name: str | list[pli.Expr] | pli.Expr | None = None) -> pli.Expr:
"""
Do one of two things.
Expand Down Expand Up @@ -1014,7 +1014,7 @@ def all(name: str | list[pli.Expr] | None = None) -> pli.Expr:
"""
if name is None:
return col("*")
if isinstance(name, list):
if isinstance(name, (list, pli.Expr)):
return fold(lit(True), lambda a, b: a.cast(bool) & b.cast(bool), name).alias(
"all"
)
Expand Down
18 changes: 18 additions & 0 deletions py-polars/tests/test_lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1404,3 +1404,21 @@ def test_type_coercion_unknown_4190() -> None:
.lazy()
.with_columns([pl.col("a") & pl.col("a").fill_null(True)])
).collect().shape == (3, 2)


def test_all_any_accept_expr() -> None:
df = pl.DataFrame(
{
"a": [1, None, 2],
"b": [1, 2, None],
}
)
assert df.select(
[
pl.any(pl.all().is_null()).alias("null_in_row"),
pl.all(pl.all().is_null()).alias("all_null_in_row"),
]
).to_dict(False) == {
"null_in_row": [False, True, True],
"all_null_in_row": [False, False, False],
}

0 comments on commit 8f686b1

Please sign in to comment.