code: def _change_case(
      col: Union[pd.Index, pd.Series], case_type: str
  ) -> str:
      """Change case of labels in pandas object."""
      case_types = {"preserve", "upper", "lower", "snake"}
      case_type = case_type.lower()
      if case_type not in case_types:
          raise JanitorError(f"case_type must be one of: {case_types}")
      if case_type == "preserve":
          return col
      if case_type == "upper":
          return col.str.upper()
      if case_type == "lower":
          return col.str.lower()
      # Implementation taken from: https://gist.github.com/jaytaylor/3660565
      # by @jtaylor
      return (
          col.str.replace(
              pat=r"(.)([A-Z][a-z]+)", repl=r"\1_\2", regex=True
          )
          .str.replace(
              pat=r"([a-z0-9])([A-Z])", repl=r"\1_\2", regex=True
          )
          .str.lower()
      )
  
file_path: pyjanitor/janitor/functions/clean_names.py
imports: import unicodedata
  from typing import Hashable, Optional, Union
  import pandas
  import pandas_flavor
  from pandas.api.types import is_scalar
  from janitor.errors import JanitorError
  from janitor.functions.utils import _is_str_or_cat, get_index_labels
  from janitor.utils import deprecated_alias
label_desc: Use image node_id 3 for calling a global function with example usage: _change_case(col, case_type) and returns: col, col, col, col