class_docstr: Label Encoder that groups infrequent values into one label.
  
  Code from https://github.com/jeongyoonlee/Kaggler/blob/master/kaggler/preprocessing/data.py
  
  Attributes:
      min_obs (int): minimum number of observation to assign a label.
      label_encoders (list of dict): label encoders for columns
      label_maxes (list of int): maximum of labels for columns
docstr: Return a mapping from values and its maximum of a column to integer labels.
  
  Args:
      x (pandas.Series): a categorical column to encode.
  
  Returns:
      label_encoder (dict): mapping from values of features to integers
      max_label (int): maximum label
docstr_tok: ["Return","a","mapping","from","values","and","its","maximum","of","a","column","to","integer","labels",".","Args",":","x","(","pandas.Series",")",":","a","categorical","column","to","encode",".","Returns",":","label_encoder","(","dict",")",":","mapping","from","values","of","features","to","integers","max_label","(","int",")",":","maximum","label"]
code: def _get_label_encoder_and_max(self, x):
      """Return a mapping from values and its maximum of a column to integer labels.
  
      Args:
          x (pandas.Series): a categorical column to encode.
  
      Returns:
          label_encoder (dict): mapping from values of features to integers
          max_label (int): maximum label
      """
  
      # NaN cannot be used as a key for dict. So replace it with a random integer.
      label_count = x.fillna(NAN_INT).value_counts()
      n_uniq = label_count.shape[0]
  
      label_count = label_count[label_count >= self.min_obs]
      n_uniq_new = label_count.shape[0]
  
      # If every label appears more than min_obs, new label starts from 0.
      # Otherwise, new label starts from 1 and 0 is used for all old labels
      # that appear less than min_obs.
      offset = 0 if n_uniq == n_uniq_new else 1
  
      label_encoder = pd.Series(
          np.arange(n_uniq_new) + offset, index=label_count.index
      )
      max_label = label_encoder.max()
      label_encoder = label_encoder.to_dict()
  
      return label_encoder, max_label
  
imports: import logging
  import numpy
  import pandas
  from scipy import sparse
  from sklearn import base
label_desc: Use image node_id 3 for calling the LabelEncoder obj's underlying member method code with example usage: obj._get_label_encoder_and_max(x) and returns: label_encoder,  max_label