code: def _categorize(df: DataFrame, cat_cols: List, codes) -> DataFrame:
      # apply codes to each column
      for col in cat_cols:
          df[col] = pd.Categorical(
              df[col], categories=codes[col], ordered=True
          )
      df[cat_cols] = df[cat_cols].apply(lambda x: x.cat.codes)
  
      # we add one here as Nones are -1, so they turn into 0's
      df[cat_cols] = df[cat_cols] + 1
      return df
  
file_path: lightning-flash/src/flash/tabular/classification/utils.py
imports: import logging
  from typing import Dict, List, Tuple
  import numpy
  from flash.core.utilities.imports import _PANDAS_AVAILABLE
label_desc: Use image node_id 5 for calling a global function with example usage: _categorize(df, cat_cols, codes) and returns: df