polars.Expr.map.contains_key#

Expr.map.contains_key(key: IntoExpr) → Expr[source]#

Check whether every map holds key.

engine:In MemoryStreamingDistributed
Parameters:
key

Key to look up. A single value is broadcast over all maps. It is cast to the map’s key type, and a key the cast cannot represent exactly, because it is out of range or would be rounded, is absent.

Returns:
Expr

Expression of data type Boolean.

Examples

>>> df = pl.DataFrame(
...     {
...         "m": pl.Series(
...             [{"a": 1, "b": 2}, {}, None], dtype=pl.Map(pl.String, pl.Int64)
...         )
...     }
... )
>>> df.select(pl.col("m").map.contains_key("a"))
shape: (3, 1)
┌───────┐
│ m     │
│ ---   │
│ bool  │
╞═══════╡
│ true  │
│ false │
│ null  │
└───────┘