test = {
'A': [0.1, 33, -5],
'B': [1, -7, np.nan]
}
df = pd.DataFrame(test)
df > 0
df[df > 0]
df.mask(df > 0)
The mask method is an application of the if-then idiom. For each element in the calling DataFrame, if cond is False the element is used;
otherwise the corresponding element from the DataFrame other is used.
df.mask(df > 0, other=100)
df.where(df > 0)
The where method is an application of the if-then idiom. For each element in the calling DataFrame, if cond is True the element is used;
otherwise the corresponding element from the DataFrame other is used.
df.where(df > 0)