code: def is_categorical(series: pd.Series, counts: dict) -> bool:
      # keys = counts["value_counts_without_nan"].keys()
      # TODO: CHECK THIS CASE ACTUALLY WORKS
      # UPDATE 11-2023: NO IT DIDN'T!!! using series, not... keys (?!)
      if isinstance(
          series.dtype, pd.CategoricalDtype
      ):  # Deprecated in Pandas 2.1.3: pd.api.types.is_categorical_dtype(keys):
          return True
      elif pd.api.types.is_numeric_dtype(series) and counts[
          "distinct_count_without_nan"
      ] <= config["Type_Detection"].getint(
          "max_numeric_distinct_to_be_categorical"
      ):
          return True
      else:
          if counts["num_rows_with_data"] == 0:
              return False
          num_distinct = counts["distinct_count_without_nan"]
          fraction_distinct = num_distinct / float(
              counts["num_rows_with_data"]
          )
          if fraction_distinct > config["Type_Detection"].getfloat(
              "max_text_fraction_distinct_to_be_categorical"
          ):
              return False
          if num_distinct <= config["Type_Detection"].getint(
              "max_text_distinct_to_be_categorical"
          ):
              return True
      return False
  
file_path: sweetviz/sweetviz/from_profiling_pandas.py
imports: from urllib.parse import urlparse
  from pathlib import Path
  import pandas
  from sweetviz.config import config
label_desc: Use image node_id 2 for calling a global function with example usage: is_categorical(series, counts) and returns: False, True, True, False, False, True