-
Notifications
You must be signed in to change notification settings - Fork 185
Open
Description
df = pd.DataFrame({'a': [1, 2, 3], 'b': [0,1,6]})
print(nw.from_native(df).select(nw.when(nw.col('a', 'b')>1).then(999).otherwise(666)))
df = pl.DataFrame({'a': [1, 2, 3], 'b': [0,1,6]})
print(df.select(pl.when(pl.col('a', 'b')>1).then(999).otherwise(666)))Narwhals returns
┌──────────────────┐
|Narwhals DataFrame|
|------------------|
| literal |
| 0 666 |
| 1 666 |
| 2 999 |
└──────────────────┘
but Polars expands the predicate and ends up with
polars.exceptions.DuplicateError: the name 'literal' is duplicate
It's possible that multiple expressions are returning the same default column name. If this is the case, try renaming the columns with `.alias("new_name")` to avoid duplicate column names.As a consequence, Polars allows
pl.when(pl.all()>1).then(pl.all())but we don't
Reactions are currently unavailable