class_docstr: Find new categories in the test set.
  
  Parameters
  ----------
  columns : Union[Hashable, List[Hashable]] , default: None
      Columns to check, if none are given checks all columns except ignored ones.
  ignore_columns : Union[Hashable, List[Hashable]] , default: None
      Columns to ignore, if none given checks based on columns variable.
  max_features_to_show : int , default: 5
      maximum features with new categories to show
  max_new_categories_to_show : int , default: 5
      maximum new categories to show in feature
  aggregation_method: Optional[str], default: 'max'
      {feature_aggregation_method_argument:2*indent}
  n_samples : int , default: 10_000_000
      number of samples to use for this check.
  random_state : int, default: 42
      random seed for all check internals.
class_docstr_tok: ["Find","new","categories","in","the","test","set",".","Parameters","--","--","--","--","--","columns",":","Union","[","Hashable",",","List","[","Hashable","]","]",",","default",":","None","Columns","to","check",",","if","none","are","given","checks","all","columns","except","ignored","ones",".","ignore_columns",":","Union","[","Hashable",",","List","[","Hashable","]","]",",","default",":","None","Columns","to","ignore",",","if","none","given","checks","based","on","columns","variable",".","max_features_to_show",":","int",",","default",":","5","maximum","features","with","new","categories","to","show","max_new_categories_to_show",":","int",",","default",":","5","maximum","new","categories","to","show","in","feature","aggregation_method",":","Optional","[","str","]",",","default",":","'max'","{","feature_aggregation_method_argument:2","*","indent","}","n_samples",":","int",",","default",":","10_000_000","number","of","samples","to","use","for","this","check",".","random_state",":","int",",","default",":","42","random","seed","for","all","check","internals","."]
docstr: Add condition - require column's number of different new categories to be less or equal to threshold.
  
  Parameters
  ----------
  max_new : int , default: 0
      Number of different categories value types which is the maximum allowed.
docstr_tok: ["Add","condition","-","require","column","'s","number","of","different","new","categories","to","be","less","or","equal","to","threshold",".","Parameters","--","--","--","--","--","max_new",":","int",",","default",":","0","Number","of","different","categories","value","types","which","is","the","maximum","allowed","."]
code: def add_condition_new_categories_less_or_equal(
      self, max_new: int = 0
  ):
      """Add condition - require column's number of different new categories to be less or equal to threshold.
  
      Parameters
      ----------
      max_new : int , default: 0
          Number of different categories value types which is the maximum allowed.
      """
  
      def condition(result: pd.DataFrame) -> ConditionResult:
          failing = result[result["# New Categories"] > max_new][
              "# New Categories"
          ]
          if len(failing) > 0:
              return ConditionResult(
                  ConditionCategory.FAIL,
                  f"Found {len(failing)} features with number"
                  f" of new categories above threshold: \n{dict(failing)}",
              )
          else:
              details = get_condition_passed_message(
                  len(result), feature=True
              )
              if any(result["# New Categories"] > 0):
                  new_categories_columns = dict(
                      result[result["# New Categories"] > 0][
                          "# New Categories"
                      ][:5]
                  )
                  details += f". Top features with new categories count: \n{new_categories_columns}"
              return ConditionResult(ConditionCategory.PASS, details)
  
      return self.add_condition(
          f"Number of new category values is less or equal to {max_new}",
          condition,
      )
  
file_path: deepchecks/deepchecks/tabular/checks/train_test_validation/new_category_train_test.py
imports: from typing import Dict, List, Optional, Union
  import pandas
  from deepchecks.core import CheckResult, ConditionCategory, ConditionResult
  from deepchecks.core.reduce_classes import ReduceFeatureMixin
  from deepchecks.tabular import Context, TrainTestCheck
  from deepchecks.tabular._shared_docs import docstrings
  from deepchecks.tabular.utils.messages import get_condition_passed_message
  from deepchecks.utils.dataframes import select_from_dataframe
  from deepchecks.utils.strings import format_number, format_percent
  from deepchecks.utils.typing import Hashable
label_desc: Use image node_id 4 for calling the NewCategoryTrainTest obj's underlying member method code with example usage: obj.add_condition_new_categories_less_or_equal(max_new) and returns: self, ConditionResult, ConditionResult