from sklearn.base import TransformerMixin
import numpy as np

class FillnaMeanTransformer(TransformerMixin):
    def __init__(self, columns_to_fill):
        self.columns_to_fill = columns_to_fill


    def fit(self, df=None, y=None):
        return self

    def transform(self, df):
        df_copy = df.copy()
        try:
            for column in self.columns_to_fill:
                column_copy = df_copy[[column]]
                column_copy = column_copy.dropna()
                moyenne_colonne = np.mean(column_copy)
                values = {column: float(moyenne_colonne)}
                df.fillna(value=values, inplace=True)
            return df

        except KeyError:
            cols_error = list(set(self.columns) - set(df.columns))
            raise KeyError("The DataFrame does not include the columns: %s" % cols_error)
8d803b9485dc05dca85896834cb91bf84a767a5e
<mask token>


class FillnaMeanTransformer(TransformerMixin):
    <mask token>
    <mask token>
    <mask token>

<mask token>


class FillnaMeanTransformer(TransformerMixin):
    <mask token>

    def fit(self, df=None, y=None):
        return self

    def transform(self, df):
        df_copy = df.copy()
        try:
            for column in self.columns_to_fill:
                column_copy = df_copy[[column]]
                column_copy = column_copy.dropna()
                moyenne_colonne = np.mean(column_copy)
                values = {column: float(moyenne_colonne)}
                df.fillna(value=values, inplace=True)
            return df
        except KeyError:
            cols_error = list(set(self.columns) - set(df.columns))
            raise KeyError('The DataFrame does not include the columns: %s' %
                cols_error)

<mask token>


class FillnaMeanTransformer(TransformerMixin):

    def __init__(self, columns_to_fill):
        self.columns_to_fill = columns_to_fill

    def fit(self, df=None, y=None):
        return self

    def transform(self, df):
        df_copy = df.copy()
        try:
            for column in self.columns_to_fill:
                column_copy = df_copy[[column]]
                column_copy = column_copy.dropna()
                moyenne_colonne = np.mean(column_copy)
                values = {column: float(moyenne_colonne)}
                df.fillna(value=values, inplace=True)
            return df
        except KeyError:
            cols_error = list(set(self.columns) - set(df.columns))
            raise KeyError('The DataFrame does not include the columns: %s' %
                cols_error)

from sklearn.base import TransformerMixin
import numpy as np


class FillnaMeanTransformer(TransformerMixin):

    def __init__(self, columns_to_fill):
        self.columns_to_fill = columns_to_fill

    def fit(self, df=None, y=None):
        return self

    def transform(self, df):
        df_copy = df.copy()
        try:
            for column in self.columns_to_fill:
                column_copy = df_copy[[column]]
                column_copy = column_copy.dropna()
                moyenne_colonne = np.mean(column_copy)
                values = {column: float(moyenne_colonne)}
                df.fillna(value=values, inplace=True)
            return df
        except KeyError:
            cols_error = list(set(self.columns) - set(df.columns))
            raise KeyError('The DataFrame does not include the columns: %s' %
                cols_error)

from sklearn.base import TransformerMixin
import numpy as np

class FillnaMeanTransformer(TransformerMixin):
    def __init__(self, columns_to_fill):
        self.columns_to_fill = columns_to_fill


    def fit(self, df=None, y=None):
        return self

    def transform(self, df):
        df_copy = df.copy()
        try:
            for column in self.columns_to_fill:
                column_copy = df_copy[[column]]
                column_copy = column_copy.dropna()
                moyenne_colonne = np.mean(column_copy)
                values = {column: float(moyenne_colonne)}
                df.fillna(value=values, inplace=True)
            return df

        except KeyError:
            cols_error = list(set(self.columns) - set(df.columns))
            raise KeyError("The DataFrame does not include the columns: %s" % cols_error)