code: def _as_categorical_checks(df: pd.DataFrame, **kwargs) -> dict:
      """This function raises errors if columns in `kwargs` are
      absent from the dataframe's columns.
  
      It also raises errors if the value in `kwargs`
      is not a string (`'appearance'` or `'sort'`), or a 1D array.
  
      This function is executed before proceeding to the computation phase.
  
      If all checks pass, a dictionary of column names and value is returned.
  
      Args:
          df: The pandas DataFrame object.
          **kwargs: A pairing of column name and value.
  
      Raises:
          TypeError: If `value` is not a 1-D array, or a string.
          ValueError: If `value` is a 1-D array, and contains nulls,
              or is non-unique.
  
      Returns:
          A dictionary.
      """
  
      check_column(df, kwargs)
  
      categories_dict = {}
  
      for column_name, value in kwargs.items():
          # type check
          if (value is not None) and not (
              is_list_like(value) or isinstance(value, str)
          ):
              raise TypeError(
                  f"{value} should be list-like or a string."
              )
          if is_list_like(value):
              if not hasattr(value, "shape"):
                  value = np.asarray(value)
  
              if (value.ndim != 1) or isinstance(value, pd.MultiIndex):
                  raise ValueError(
                      f"{value} is not a 1-D array. "
                      "Kindly provide a 1-D array-like object."
                  )
  
              if not isinstance(value, (pd.Series, pd.Index)):
                  value = pd.Index(value)
  
              if value.hasnans:
                  raise ValueError(
                      "Kindly ensure there are no nulls in the array provided."
                  )
  
              if not value.is_unique:
                  raise ValueError(
                      "Kindly provide unique, "
                      "non-null values for the array provided."
                  )
  
              if value.empty:
                  raise ValueError(
                      "Kindly ensure there is at least "
                      "one non-null value in the array provided."
                  )
  
              # uniques, without nulls
              uniques = df[column_name].factorize(sort=False)[-1]
              if uniques.empty:
                  raise ValueError(
                      "Kindly ensure there is at least "
                      f"one non-null value in {column_name}."
                  )
  
              missing = uniques.difference(value, sort=False)
              if not missing.empty and (uniques.size > missing.size):
                  warnings.warn(
                      f"Values {tuple(missing)} are missing from "
                      f"the provided categories {value} "
                      f"for {column_name}; this may create nulls "
                      "in the new categorical column.",
                      UserWarning,
                      stacklevel=find_stack_level(),
                  )
  
              elif uniques.equals(missing):
                  warnings.warn(
                      f"None of the values in {column_name} are in "
                      f"{value}; this might create nulls for all values "
                      f"in the new categorical column.",
                      UserWarning,
                      stacklevel=find_stack_level(),
                  )
  
          elif isinstance(value, str):
              category_order_types = {
                  ent.value for ent in _CategoryOrder
              }
              if value.lower() not in category_order_types:
                  raise ValueError(
                      "Argument should be one of 'appearance' or 'sort'."
                  )
  
          categories_dict[column_name] = value
  
      return categories_dict
  
file_path: pyjanitor/janitor/functions/encode_categorical.py
imports: import warnings
  from enum import Enum
  from typing import Any, Hashable, Iterable, Union
  import numpy
  import pandas
  import pandas_flavor
  from pandas.api.types import is_list_like
  from janitor.functions.utils import get_index_labels
  from janitor.utils import check_column, deprecated_alias, find_stack_level
label_desc: Use image node_id 3 for calling a global function with example usage: _as_categorical_checks(df) and returns: categories_dict