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