Skip to main content
`Ctrl`+`K`

# pandas.Index.putmask

Index.putmask(mask, value)

  Return a new Index of the values set with the mask.

  Replaces elements of the Index where the corresponding mask entry is `True`, returning a new Index rather than modifying in place.

  Parameters:
    mask array-like of bool

      Array of booleans denoting where values should be replaced.

    value scalar

      Scalar value to use to fill holes (e.g. 0). This value cannot be a list-likes.

  Returns:
    Index

      A new Index of the values set with the mask.

  See also

  `numpy.putmask`

    Changes elements of an array based on conditional and input values.

  Examples

      >>> idx1 = pd.Index([1, 2, 3])
      >>> idx2 = pd.Index([5, 6, 7])
      >>> idx1.putmask([True, False, False], idx2)
      Index([5, 2, 3], dtype='int64')