def _fit_count_encode(self, X_in, y):
    'Perform the count encoding.'
    X = X_in.copy(deep=True)
    if (self.cols is None):
        self.cols = X.columns.values
    self.mapping = {}
    for col in self.cols:
        if X[col].isna().any():
            if (self._handle_missing[col] == 'error'):
                raise ValueError(('Missing data found in column %s at fit time.' % (col,)))
            elif (self._handle_missing[col] not in ['count', 'return_nan', 'error']):
                raise ValueError(('%s key in `handle_missing` should be one of:  `value`, `return_nan` and `error`.' % (col,)))
        self.mapping[col] = X[col].value_counts(normalize=self._normalize[col], dropna=False)
        if (self._handle_missing[col] == 'return_nan'):
            self.mapping[col][np.NaN] = np.NaN
    if any([(val is not None) for val in self._min_group_size.values()]):
        self.combine_min_categories(X)
Perform the count encoding.
def _fit_count_encode(self, X_in, y):
    
    X = X_in.copy(deep=True)
    if (self.cols is None):
        self.cols = X.columns.values
    self.mapping = {}
    for col in self.cols:
        if X[col].isna().any():
            if (self._handle_missing[col] == 'error'):
                raise ValueError(('Missing data found in column %s at fit time.' % (col,)))
            elif (self._handle_missing[col] not in ['count', 'return_nan', 'error']):
                raise ValueError(('%s key in `handle_missing` should be one of:  `value`, `return_nan` and `error`.' % (col,)))
        self.mapping[col] = X[col].value_counts(normalize=self._normalize[col], dropna=False)
        if (self._handle_missing[col] == 'return_nan'):
            self.mapping[col][np.NaN] = np.NaN
    if any([(val is not None) for val in self._min_group_size.values()]):
        self.combine_min_categories(X)