code: def onehot_categorizer(
      df: pd.DataFrame,
      columns_to_categorize: List[str],
      hardcode_nans: bool = False,
      drop_first_column: bool = False,
      store_mapping: bool = False,
  ) -> LearnerReturnType:
      """
      Onehot encoding on categorical columns.
      Encoded columns are removed and substituted by columns named
      `fklearn_feat__col==val`, where `col` is the name of the column
      and `val` is one of the values the feature can assume.
  
      The default behaviour is to replace the original values. To store
      the original values in a new column, specify `prefix` or `suffix`
      in the parameters, or specify a dictionary with the desired column
      mapping using the `columns_mapping` parameter.
  
      Parameters
      ----------
      df : pd.DataFrame
          A Pandas' DataFrame that must contain `columns_to_categorize` columns.
  
      columns_to_categorize : list of str
          A list of categorical column names. Must be non-empty.
  
      hardcode_nans : bool
          Hardcodes an extra column with: 1 if nan or unseen else 0.
  
      drop_first_column : bool
          Drops the first column to create (k-1)-sized one-hot arrays for k
          features per categorical column. Can be used to avoid colinearity.
  
      store_mapping : bool (default: False)
          Whether to store the feature value -> integer dictionary in the log
      """
  
      categ_getter = lambda col: list(
          np.sort(df[col].dropna(axis=0, how="any").unique())
      )
      vec = {
          column: categ_getter(column)
          for column in sorted(columns_to_categorize)
      }
  
      def p(new_df: pd.DataFrame) -> pd.DataFrame:
          make_dummies = lambda col: dict(
              map(
                  lambda categ: (
                      "fklearn_feat__" + col + "==" + str(categ),
                      (new_df[col] == categ).astype(int),
                  ),
                  vec[col][int(drop_first_column) :],
              )
          )
  
          oh_cols = dict(
              mapcat(
                  lambda col: merge(
                      make_dummies(col),
                      {
                          "fklearn_feat__"
                          + col
                          + "=="
                          + "nan": (~new_df[col].isin(vec[col])).astype(
                              int
                          )
                      }
                      if hardcode_nans
                      else {},
                  ).items(),
                  columns_to_categorize,
              )
          )
  
          return new_df.assign(**oh_cols).drop(
              columns_to_categorize, axis=1
          )
  
      p.__doc__ = learner_pred_fn_docstring("onehot_categorizer")
  
      log = {
          "onehot_categorizer": {
              "transformed_column": columns_to_categorize,
              "hardcode_nans": hardcode_nans,
              "drop_first_column": drop_first_column,
          }
      }
  
      if store_mapping:
          log["onehot_categorizer"]["mapping"] = vec
  
      return p, p(df), log
  
imports: from typing import Any, Callable, Dict, List, Union, Optional
  import numpy
  import pandas
  from numpy import nan
  from sklearn.preprocessing import StandardScaler
  from statsmodels.distributions import empirical_distribution
  from toolz import curry, merge, compose, mapcat
  from fklearn.common_docstrings import learner_return_docstring, learner_pred_fn_docstring
  from fklearn.training.utils import log_learner_time
  from fklearn.types import LearnerReturnType, LearnerLogType
  from fklearn.preprocessing.schema import column_duplicatable
label_desc: Use image node_id 14 for calling a global function with example usage: onehot_categorizer(df, columns_to_categorize, hardcode_nans, drop_first_column, store_mapping) and returns: p,  p,  log, new_df