docstr: Builds a pandas query for the given include or
  exclude bounds filter.
  
  :param filter: The categorical filter or composite_filter to apply to
      the dataset.
  :type filter: list[dict]
  :param colname: The column name to filter on.
  :type colname: str
  :param method: The method type, in this method one of include or
                 exclude.
  :type method: str
  :param categorical_features: The categorical feature names.
  :type categorical_features: list[str]
  :param categories: The list of categorical values for the categorical
      features.
  :type categories: list[list]
  :return: The built pandas bounds query.
  :rtype: str
docstr_tok: ["Builds","a","pandas","query","for","the","given","include","or","exclude","bounds","filter",".",":","param","filter",":","The","categorical","filter","or","composite_filter","to","apply","to","the","dataset",".",":","type","filter",":","list","[","dict","]",":","param","colname",":","The","column","name","to","filter","on",".",":","type","colname",":","str",":","param","method",":","The","method","type",",","in","this","method","one","of","include","or","exclude",".",":","type","method",":","str",":","param","categorical_features",":","The","categorical","feature","names",".",":","type","categorical_features",":","list","[","str","]",":","param","categories",":","The","list","of","categorical","values","for","the","categorical","features",".",":","type","categories",":","list","[","list","]",":","return",":","The","built","pandas","bounds","query",".",":","rtype",":","str"]
code: def _build_bounds_query(
      self, filter, colname, method, categorical_features, categories
  ):
      """Builds a pandas query for the given include or
      exclude bounds filter.
  
      :param filter: The categorical filter or composite_filter to apply to
          the dataset.
      :type filter: list[dict]
      :param colname: The column name to filter on.
      :type colname: str
      :param method: The method type, in this method one of include or
                     exclude.
      :type method: str
      :param categorical_features: The categorical feature names.
      :type categorical_features: list[str]
      :param categories: The list of categorical values for the categorical
          features.
      :type categories: list[list]
      :return: The built pandas bounds query.
      :rtype: str
      """
      bounds = []
      if method == CohortFilterMethods.METHOD_EXCLUDES:
          operator = " != "
      else:
          operator = " == "
      is_categorical = False
      if categorical_features:
          is_categorical = colname in categorical_features
      is_label = False
      if colname == TRUE_Y or colname == PRED_Y:
          is_label = True
      for arg in filter[ARG]:
          if is_categorical:
              cat_idx = categorical_features.index(colname)
              if isinstance(categories[cat_idx][arg], str):
                  arg_val = "'{}'".format(str(categories[cat_idx][arg]))
              else:
                  arg_val = "{}".format(str(categories[cat_idx][arg]))
          elif is_label and self.classes is not None:
              class_value = self.classes[arg]
              format_str = "{}"
              if isinstance(class_value, str):
                  format_str = "'{}'"
              arg_val = format_str.format(str(self.classes[arg]))
          else:
              arg_val = arg
          bounds.append("`{}`{}{}".format(colname, operator, arg_val))
      if method == CohortFilterMethods.METHOD_EXCLUDES:
          return " & ".join(bounds)
      else:
          return " | ".join(bounds)
  
file_path: responsible-ai-toolbox/erroranalysis/erroranalysis/_internal/cohort_filter.py
imports: from typing import Any, List, Optional
  import numpy
  import pandas
  from erroranalysis._internal.constants import ARG, COLUMN, COMPOSITE_FILTERS, METHOD, OPERATION, PRED_Y, ROW_INDEX, TRUE_Y, CohortFilterMethods, CohortFilterOps, ModelTask
  from erroranalysis._internal.metrics import get_ordered_classes
  from erroranalysis._internal.utils import is_spark
label_desc: Use image node_id 12 for calling the FilterDataWithCohortFilters obj's underlying member method code with example usage: obj._build_bounds_query(filter, colname, method, categorical_features, categories) and returns: str, str