how to assign zero for null value in a columns python code example
Example 1: pandas replace nulls with zeros
df['col1'] = df['col1'].fillna(0)
Example 2: how to replace zero value in python dataframe
nonzero_mean = df[ df.col != 0 ].mean()
df['col1'] = df['col1'].fillna(0)
nonzero_mean = df[ df.col != 0 ].mean()