polars.Expr.meta.is_literal#

Expr.meta.is_literal(*, allow_aliasing: bool = False) bool[source]#

Indicate if this expression is a literal value (optionally aliased).

Added in version 1.14.

Parameters:
allow_aliasing

If False (default), only a bare literal will match. Set True to also allow for aliased literals.

Examples

>>> from datetime import datetime
>>> e = pl.lit(123)
>>> e.meta.is_literal()
True
>>> e = pl.lit(987.654321).alias("foo")
>>> e.meta.is_literal()
False
>>> e = pl.lit(datetime.now()).alias("bar")
>>> e.meta.is_literal(allow_aliasing=True)
True