This can be done very easily before or after using the DataFrameMapper
:
df_filtered = df [~df['specific column name'].isnull()]
To do it using the DataFrameMapper
itself, you would need to build a transformer as so:
class DropNullTransformer(BaseEstimator, TransformerMixin):
def __init__(self, column):
self.column = column
def fit(self, X, y=None):
return self
def transform(self, X):
return X.dropna(subset=[self.column])
From there, you include this transformer when building the DataFrameMapper
:
dfm = DataFrameMapper([
([specificColumnName], DropNullTransformer(specificColumnName))
])
Then, the fit and transformation function will perform the drop for you. To learn more about custom transformers, you can read the Sklearn guide.