docstr: Adds special columns to the dataset for filtering
  and postprocessing.
  
  :param df: The dataset as a pandas dataframe.
  :type df: pandas.DataFrame
  :param filters: The filters.
  :type filters: list[dict]
docstr_tok: ["Adds","special","columns","to","the","dataset","for","filtering","and","postprocessing",".",":","param","df",":","The","dataset","as","a","pandas","dataframe",".",":","type","df",":","pandas.DataFrame",":","param","filters",":","The","filters",".",":","type","filters",":","list","[","dict","]"]
code: def _add_filter_cols(self, df, filters):
      """Adds special columns to the dataset for filtering
      and postprocessing.
  
      :param df: The dataset as a pandas dataframe.
      :type df: pandas.DataFrame
      :param filters: The filters.
      :type filters: list[dict]
      """
      has_classification_outcome = (
          self._filters_has_classification_outcome(filters)
      )
      has_regression_error = self._filters_has_regression_error(filters)
  
      if isinstance(self.true_y, str):
          df.rename(columns={self.true_y: TRUE_Y})
      else:
          df[TRUE_Y] = self.true_y
  
      if self.model is None:
          df[PRED_Y] = self.pred_y
  
      if not is_spark(df):
          df[ROW_INDEX] = np.arange(0, len(self.true_y))
      if has_classification_outcome:
          if PRED_Y in df:
              pred_y = df[PRED_Y]
          else:
              # calculate directly via prediction on model
              pred_y = self.model.predict(
                  df.drop(columns=[TRUE_Y, ROW_INDEX])
              )
  
          classes = get_ordered_classes(
              self.classes, self.true_y, pred_y
          )
  
          # calculate classification outcome and add to df
          if len(classes) == 2:
              df[
                  CLASSIFICATION_OUTCOME
              ] = self._compute_binary_classification_outcome_data(
                  self.true_y, pred_y, classes
              )
          else:
              df[
                  CLASSIFICATION_OUTCOME
              ] = self._compute_multiclass_classification_outcome_data(
                  self.true_y, pred_y
              )
      elif has_regression_error:
          if PRED_Y in df:
              pred_y = df[PRED_Y]
          else:
              # calculate directly via prediction on model
              pred_y = self.model.predict(
                  df.drop(columns=[TRUE_Y, ROW_INDEX])
              )
          # calculate regression error and add to df
          df[REGRESSION_ERROR] = self._compute_regression_error_data(
              self.true_y, pred_y
          )
  
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 8 for calling the FilterDataWithCohortFilters obj's underlying member method code with example usage: obj._add_filter_cols(df, filters) without return types