Conditional value selection using CASE WHEN semantics — mirrors pandas.Series.case_when() (pandas 2.2+).
caseWhen(series, caselist) applies an ordered list of [condition, replacement] pairs. The first matching condition determines the output; if no condition matches the original value is kept.
Conditions can be boolean Series objects (e.g. from comparison operations).
Conditions can be predicate functions (value, index) => boolean.
Replacements can be Series objects — the matching positional value is used.
Any row not matched by any condition retains its original value — there is no implicit "else" replacement.
When multiple conditions match the same row, the first one in caselist takes effect — just like CASE WHEN … THEN … WHEN … THEN … END in SQL.
Predicate functions receive both the value and its positional index as the second argument.
caseWhen works on any Series type — numbers, strings, booleans, or mixed.
caseWhen generalises whereSeries to multiple branches. Use whereSeries for a single condition; use caseWhen for multi-branch logic.