In [5]: df.mask(df < 0, 0) Out[5]: a b 0 0 0 1 0 2 2 2 1
import numpy as np arr = np.array([9, -np.inf, 0, 1]) rep_val = 0 arr.replace(-np.inf, rep_val, inplace = True)