Series.
mask
Replace values where the condition is True.
Where cond is False, keep the original value. Where True, replace with corresponding value from other.
Entries where cond is True are replaced with corresponding value from other.
Examples
>>> from databricks.koalas.config import set_option, reset_option >>> set_option("compute.ops_on_diff_frames", True) >>> s1 = ks.Series([0, 1, 2, 3, 4]) >>> s2 = ks.Series([100, 200, 300, 400, 500]) >>> s1.mask(s1 > 0).sort_index() 0 0.0 1 NaN 2 NaN 3 NaN 4 NaN Name: 0, dtype: float64
>>> s1.mask(s1 > 1, 10).sort_index() 0 0 1 1 2 10 3 10 4 10 Name: 0, dtype: int64
>>> s1.mask(s1 > 1, s1 + 100).sort_index() 0 0 1 1 2 102 3 103 4 104 Name: 0, dtype: int64
>>> s1.mask(s1 > 1, s2).sort_index() 0 0 1 1 2 300 3 400 4 500 Name: 0, dtype: int64
>>> reset_option("compute.ops_on_diff_frames")