how to replace zero values with nan python code example
Example 1: how to replace zero with null in python
df2[["Weight","Height","BootSize","SuitSize"]].astype(str).replace('0',np.nan)
Example 2: how to replace zero with null in python
df2.loc[df2['Weight'] == 0,'Weight'] = np.nan
df2.loc[df2['Height'] == 0,'Height'] = np.nan
df2.loc[df2['BootSize'] == '0','BootSize'] = np.nan
df2.loc[df2['SuitSize'] == '0','SuitSize'] = np.nan