最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Default filter expression to "match anything" - Stack Overflow

programmeradmin1浏览0评论

What kind of polars expression (pl.Expr) might be used in a filter context that will match anything including nulls?

Use case: Type hinting and helper Functions that should return an polars.Expr.

What kind of polars expression (pl.Expr) might be used in a filter context that will match anything including nulls?

Use case: Type hinting and helper Functions that should return an polars.Expr.

Share Improve this question edited Feb 10 at 17:52 jqurious 21.6k4 gold badges20 silver badges39 bronze badges asked Feb 10 at 17:36 Gregg LindGregg Lind 21.3k15 gold badges69 silver badges81 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 5

The expression representing the literal value True might be used. See pl.lit for more details.

Example.

import polars as pl

df = pl.DataFrame({
    "a": [1, 2, None]
})

df.filter(pl.lit(True))
shape: (3, 1)
┌──────┐
│ a    │
│ ---  │
│ i64  │
╞══════╡
│ 1    │
│ 2    │
│ null │
└──────┘

Note. In general, simply True also works, but its not an instance of pl.Expr.

发布评论

评论列表(0)

  1. 暂无评论