how to replace 0 from the dataframe code example Example: how to replace zero value in python dataframe nonzero_mean = df[ df.col != 0 ].mean()