Examples

In [1]:
import numpy as np
import pandas as pd
In [2]:
s = pd.Series(range(6))
s.where(s > 0)
Out[2]:
0    NaN
1    1.0
2    2.0
3    3.0
4    4.0
5    5.0
dtype: float64
In [3]:
s.mask(s > 0)
Out[3]:
0    0.0
1    NaN
2    NaN
3    NaN
4    NaN
5    NaN
dtype: float64