-
Notifications
You must be signed in to change notification settings - Fork 182
Open
Description
Describe the bug
not sure if this is a bug or intended, but behaviour for nw.Expr.str.contains does not match polars when an expr is passed as the match argument
Steps or code to reproduce the bug
import polars as pl
import narwhals as nw
df = pl.DataFrame(
{
'a': ['x', 'y'],
'b': ['x', 'z']
}
)
df = nw.from_native(df)
df.with_columns(
nw.col('a').str.contains(nw.col('b'), literal=True)
)TypeError: cannot create expression literal for value of type Expr.
Expected results
Running directly in polars gives the expected result:
shape: (2, 2)
┌───────┬─────┐
│ a ┆ b │
│ --- ┆ --- │
│ bool ┆ str │
╞═══════╪═════╡
│ true ┆ x │
│ false ┆ z │
└───────┴─────┘
Actual results
TypeError: cannot create expression literal for value of type Expr.
Please run narwhals.show_versions() and enter the output below.
System:
python: 3.12.12 (main, Oct 14 2025, 21:38:21) [Clang 20.1.4 ]
executable: /Users/liamholmes/Documents/Code/narwhals/.venv/bin/python
machine: macOS-14.5-arm64-arm-64bit
Python dependencies:
narwhals: 2.14.0
numpy: 2.3.4
pandas: 2.3.3
modin: 0.37.1
cudf:
pyarrow: 22.0.0
pyspark:
polars: 1.34.0
dask: 2025.11.0
duckdb: 1.3.0
ibis: 11.0.0
sqlframe: 3.43.8Reactions are currently unavailable