maxframe.liteframe.LiteFrame.mask#

LiteFrame.mask(cond, other=nan)#

Replace values where cond is True with other.

Equivalent to pandas.DataFrame.mask: replace original values where cond is True with other, keep where False.

Parameters:
  • cond (LiteFrame) – Boolean LiteFrame (e.g. from lf > 2) with the same columns.

  • other (scalar or LiteFrame, default np.nan) – Value to substitute where cond is True.

Return type:

LiteFrame

See also

where

Replace values where a condition is False.

case_when

Replace values where conditions are True, in order.

Examples

>>> import maxframe.liteframe as mlf
>>> lf = mlf.LiteFrame({'a': [1, 2, 3]})
>>> result = lf.mask(lf > 2, 0)
>>> result.execute()
   a
0  1
1  2
2  0