Replace zero in DataFrame
Null
The replace_zero() function replaces any zero value in the given dataframe column with the median value of the dataframe.
Filename pattern: .ipynb, .py
import pandas as pd
def replace_zero(dataframe, column):
median = dataframe[column].median()
dataframe.replace(to_replace=0, value=median, inplace=True)
return dataframe