I'd like to replace any value greater than some condition with zero for any column except the date column in a df. The closest I've found it
df.with_columns(
pl.when(pl.any_horizontal(pl.col(pl.Float32) > 20))
.then(0)
.otherwise(pl.col(pl.Float32))
)
But this will zero out the entire row.
My not working code is -
df=df.select(
pl.col("date"),
pl.when(pl.col(pl.Float32) > 20).then(0))
In Pandas I would do something like
df.where(df>2, 0)
minimal working codewith small example data directly in code (and with expected output) - so we could simply copy and test it.