code: def partition_column(
      dataset: Dataset,
      column_name: Hashable,
      max_segments: int = 10,
      max_cat_proportions: float = 0.9,
  ) -> List[DeepchecksFilter]:
      """Split column into segments.
  
      For categorical we'll have a max of max_segments + 1, for the 'Others'. We take the largest categories which
      cumulative percent in data is equal/larger than `max_cat_proportions`. the rest will go to 'Others' even if less
      than max_segments.
      For numerical we split into maximum number of `max_segments` quantiles. if some of the quantiles are duplicates
      then we merge them into the same segment range (so not all ranges necessarily will have same size).
  
      Parameters
      ----------
      dataset : Dataset
      column_name : Hashable
          column to partition.
      max_segments : int, default: 10
          maximum number of segments to split into.
      max_cat_proportions : float , default: 0.9
          (for categorical) ratio to aggregate largest values to show.
  
      Returns
      -------
      List[DeepchecksFilter]
      """
      column = dataset.data[column_name]
      if column_name in dataset.numerical_features:
          percentile_values = numeric_segmentation_edges(
              column, max_segments
          )
          # If for some reason only single value in the column (and column not categorical) we will get single item
          if len(percentile_values) == 1:
              f = lambda df, val=percentile_values[0]: (
                  df[column_name] == val
              )
              label = str(percentile_values[0])
              return [DeepchecksFilter([f], label)]
  
          filters = []
          for start, end in zip(
              percentile_values[:-1], percentile_values[1:]
          ):
              # In case of the last range, the end is closed.
              if end == percentile_values[-1]:
                  f = lambda df, a=start, b=end: (
                      df[column_name] >= a
                  ) & (df[column_name] <= b)
                  label = (
                      f"[{format_number(start)} - {format_number(end)}]"
                  )
              else:
                  f = lambda df, a=start, b=end: (
                      df[column_name] >= a
                  ) & (df[column_name] < b)
                  label = (
                      f"[{format_number(start)} - {format_number(end)})"
                  )
  
              filters.append(DeepchecksFilter([f], label))
          return filters
      elif column_name in dataset.cat_features:
          # Get sorted histogram
          cat_hist_dict = column.value_counts()
          # Get index of last value in histogram to show
          n_large_cats = largest_category_index_up_to_ratio(
              cat_hist_dict, max_segments, max_cat_proportions
          )
  
          filters = []
          for i in range(n_large_cats):
              f = (
                  lambda df, val=cat_hist_dict.index[i]: df[column_name]
                  == val
              )
              filters.append(
                  DeepchecksFilter([f], str(cat_hist_dict.index[i]))
              )
  
          if len(cat_hist_dict) > n_large_cats:
              f = lambda df, values=cat_hist_dict.index[
                  :n_large_cats
              ]: ~df[column_name].isin(values)
              filters.append(DeepchecksFilter([f], "Others"))
  
          return filters
  
imports: from collections import defaultdict
  from copy import deepcopy
  from typing import Callable, List, Optional, Tuple, Union
  import numpy
  import pandas
  from sklearn.tree import _tree
  from deepchecks.tabular.dataset import Dataset
  from deepchecks.utils.strings import format_number
  from deepchecks.utils.typing import Hashable
label_desc: Use image node_id 5 for calling a global function with example usage: partition_column(dataset, column_name, max_segments, max_cat_proportions) and returns: filters, list, filters