I just failed an audit for the following question: Use polars when-then-otherwise on multiple output columns at once. The correct response was "Looks OK," but I flagged as a duplicate because one comment linked to How can I use when, then and otherwise with multiple conditions in polars?, which seems to be asking something similar. Both seem to be about using polars when-then-otherwise to set multiple columns simultaneously.
In addition to the similarities in the questions themselves, I noticed that the top answer for the first question:
cols = ['value', 'value_other', 'value_other2']
(df.with_columns(
pl.when(pl.col('value').is_null() & (pl.col('quantity') == 0))
.then(0)
.otherwise(pl.col(cols))
.name.keep()
))
Was very similar to the accepted answer for the second question:
df.with_columns(
pl.when(pl.col("A").is_in(["foo", "spam"]))
.then(pl.lit("XX"))
.otherwise(pl.col("L", "G"))
.name.keep()
)
Was flagging the correct choice, or should I have marked it as "Looks OK"?
[closed]
designation. You won't get enough eyeballs to reopen, even if the question is deserving.