return df
def transform(self, data):
data = _check_object_col(data, "data")
// drop null columns
data.dropna(axis=1, how="all", inplace=True)
if self.strategy == "zero":
for col in data.columns:
data[col].fillna(value=0,inplace=True)
return data
elif self.strategy == "ignore_row":
data.dropna(axis=0, how="any", inplace=True)
return data
elif self.strategy == "ignore_column":
data.dropna(axis=1, how="any", inplace=True)
return data
elif self.strategy == "interpolate":
data = data.interpolate()
data.fillna(method="ffill",axis=1, inplace=True) // because of nan in the first and last element of column
return data
else:
msg = "Wrong strategy has been passed"
After Change
if self.strategy == "ignore_row":
return df[self.mask]
elif self.strategy == "ignore_column":
return df.T[self.mask].T
else:
msg = "The transform method doesn"t change the dataframe if strategy="zero" or "interpolate". You should fit_transform your new dataframe with those methods."