How does Series.where(cond, other) differ from Series.mask(cond, other)?
Correct answer
A. where keeps values where the condition holds; mask replaces them there
14 views
A. where keeps values where the condition holds; mask replaces them there
14 views
where is the keep-mask: entries where the condition is True are retained and everything else is replaced by other, which defaults to NaN. mask is its complement and replaces where the condition is True. Both align on the index labels of the condition, so a condition taken from another frame silently introduces NaN wherever labels fail to match.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is A? Ask here and get an explanation.