class_docstr: ################################################################################################
  ######       The My_LabelEncoder_Pipe class was developed by Ram Seshadri for Auto_TS      #####
  ######  The My_LabelEncoder_Pipe class works just like sklearn's Label Encoder but better! #####
  #####  It label encodes any cat var in your dataset. But it can also be used in Pipelines! #####
  ##  The beauty of this function is that it takes care of NaN's and unknown (future) values.#####
  #####  Since it produces an unused second column it can be used in sklearn's Pipelines.    #####
  #####  But for that you need to add a drop_second_col() function to this My_LabelEncoder_Pipe ## 
  #####  and then feed the whole pipeline to a Column_Transformer function. It is very easy. #####
  ##################### This is the BEST working version - don't mess with it!! ##################
  ################################################################################################
  Usage in pipelines:
        le = My_LabelEncoder_Pipe()
        le.fit_transform(train[column]) ## this will give you two columns - beware!
        le.transform(test[column]) ### this will give you two columns - beware!
            
  Usage in Column Transformers:
      def drop_second_col(Xt):
      ### This deletes the 2nd column. Hence col number=1 and axis=1 ###
      return np.delete(Xt, 1, 1)
      
      drop_second_col_func = FunctionTransformer(drop_second_col)
      
      le_one = make_pipeline(le, drop_second_col_func)
  
      ct = make_column_transformer(
          (le_one, catvars[0]),
          (le_one, catvars[1]),
          (imp, numvars),
          remainder=remainder)    
class_docstr_tok: ["#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","The","My_LabelEncoder_Pipe","class","was","developed","by","Ram","Seshadri","for","Auto_TS","#","#","#","#","#","#","#","#","#","#","#","The","My_LabelEncoder_Pipe","class","works","just","like","sklearn","'s","Label","Encoder","but","better","!","#","#","#","#","#","#","#","#","#","#","It","label","encodes","any","cat","var","in","your","dataset",".","But","it","can","also","be","used","in","Pipelines","!","#","#","#","#","#","#","#","The","beauty","of","this","function","is","that","it","takes","care","of","NaN","'s","and","unknown","(","future",")","values.","#","#","#","#","#","#","#","#","#","#","Since","it","produces","an","unused","second","column","it","can","be","used","in","sklearn","'s","Pipelines",".","#","#","#","#","#","#","#","#","#","#","But","for","that","you","need","to","add","a","drop_second_col","(",")","function","to","this","My_LabelEncoder_Pipe","#","#","#","#","#","#","#","and","then","feed","the","whole","pipeline","to","a","Column_Transformer","function",".","It","is","very","easy",".","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","This","is","the","BEST","working","version","-","do","n't","mess","with","it","!","!","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","Usage","in","pipelines",":","le","=","My_LabelEncoder_Pipe","(",")","le.fit_transform","(","train","[","column","]",")","#","#","this","will","give","you","two","columns","-","beware","!","le.transform","(","test","[","column","]",")","#","#","#","this","will","give","you","two","columns","-","beware","!","Usage","in","Column","Transformers",":","def","drop_second_col","(","Xt",")",":","#","#","#","This","deletes","the","2nd","column",".","Hence","col","number=1","and","axis=1","#","#","#","return","np.delete","(","Xt",",","1",",","1",")","drop_second_col_func","=","FunctionTransformer","(","drop_second_col",")","le_one","=","make_pipeline","(","le",",","drop_second_col_func",")","ct","=","make_column_transformer","(","(","le_one",",","catvars","[","0","]",")",",","(","le_one",",","catvars","[","1","]",")",",","(","imp",",","numvars",")",",","remainder=remainder",")"]
code: def fit(self, testx, y=None):
      if isinstance(testx, pd.Series):
          pass
      elif isinstance(testx, np.ndarray):
          testx = pd.Series(testx)
      else:
          #### There is no way to transform dataframes since you will get a nested renamer error if you try ###
          ### But if it is a one-dimensional dataframe, convert it into a Series
          if testx.shape[1] == 1:
              testx = pd.Series(
                  testx.values.ravel(), name=testx.columns[0]
              )
          else:
              #### Since it is multi-dimensional, So in this case, just return the data as is
              return self
      ins = np.unique(testx.factorize()[1]).tolist()
      outs = np.unique(testx.factorize()[0]).tolist()
      # ins = testx.value_counts(dropna=False).index
      if -1 in outs:
          #   it already has nan if -1 is in outs. No need to add it.
          if not np.nan in ins:
              ins.insert(0, np.nan)
      self.transformer = dict(zip(ins, outs))
      self.inverse_transformer = dict(zip(outs, ins))
      return self
  
imports: import numpy
  import pandas
  from sklearn.impute import SimpleImputer
  from sklearn.preprocessing import OneHotEncoder
  from sklearn.feature_extraction.text import CountVectorizer
  from sklearn.linear_model import LogisticRegression
  from sklearn.compose import make_column_transformer
  from sklearn.pipeline import make_pipeline
  from sklearn.preprocessing import LabelEncoder, LabelBinarizer
  from sklearn.base import BaseEstimator, TransformerMixin
  import pdb
  from sklearn.base import TransformerMixin
  from collections import defaultdict
label_desc: Use image node_id 2 for calling the My_LabelEncoder_Pipe obj's underlying member method code with example usage: obj.fit(testx, y) and returns: self, self