Skip to content

pd.Series.mask

pandas.Series.mask(cond, other=nan, inplace=False, axis=None, level=None, errors='raise', try_cast=NoDefault.no_default)

Supported Arguments

argument datatypes
cond
  • boolean array
  • 1d bool numpy array
other
  • 1d numpy array
  • scalar

Note

Series can contain categorical data if other is a scalar

Example Usage

>>> @bodo.jit
... def f(S):
...     return S.mask((S % 3) != 0, 0)
>>> S = pd.Series(np.arange(100))
>>> f(S)
0      0
1      0
2      0
3      3
4      0
      ..
95     0
96    96
97     0
98     0
99    99
Length: 100, dtype: int64

Missing data handling