polars.Expr.bin.ends_with#
- Expr.bin.ends_with(suffix: IntoExpr) Expr [source]#
Check if string values end with a binary substring.
- Parameters:
- suffix
Suffix substring.
- Returns:
- Expr
Expression of data type
Boolean
.
See also
starts_with
Check if the binary substring exists at the start
contains
Check if the binary substring exists anywhere
Examples
>>> colors = pl.DataFrame( ... { ... "name": ["black", "yellow", "blue"], ... "code": [b"\x00\x00\x00", b"\xff\xff\x00", b"\x00\x00\xff"], ... "suffix": [b"\x00", b"\xff\x00", b"\x00\x00"], ... } ... ) >>> colors.select( ... "name", ... pl.col("code").bin.ends_with(b"\xff").alias("ends_with_lit"), ... pl.col("code").bin.ends_with(pl.col("suffix")).alias("ends_with_expr"), ... ) shape: (3, 3) ┌────────┬───────────────┬────────────────┐ │ name ┆ ends_with_lit ┆ ends_with_expr │ │ --- ┆ --- ┆ --- │ │ str ┆ bool ┆ bool │ ╞════════╪═══════════════╪════════════════╡ │ black ┆ false ┆ true │ │ yellow ┆ false ┆ true │ │ blue ┆ true ┆ false │ └────────┴───────────────┴────────────────┘