polars.Expr.is_first_distinct#
- Expr.is_first_distinct() Expr[source]#
返回一个布尔掩码,指示每个不同值的首次出现。
- Returns:
- Expr
数据类型
Boolean的表达式。
示例
>>> df = pl.DataFrame({"a": [1, 1, 2, 3, 2]}) >>> df.with_columns(pl.col("a").is_first_distinct().alias("first")) shape: (5, 2) ┌─────┬───────┐ │ a ┆ first │ │ --- ┆ --- │ │ i64 ┆ bool │ ╞═════╪═══════╡ │ 1 ┆ true │ │ 1 ┆ false │ │ 2 ┆ true │ │ 3 ┆ true │ │ 2 ┆ false │ └─────┴───────┘