docstr: Category encode the given columns.
  
  :param df: a pyspark.sql.dataframe.DataFrame to be processed.
  :param columns: str or a list of str, target columns to encode from string to index.
  :param freq_limit: int, dict or None. Categories with a count/frequency below freq_limit
         will be omitted from the encoding. Can be represented as either an integer,
         dict. For instance, 15, {'col_4': 10, 'col_5': 2} etc. Default is None,
         and in this case all the categories that appear will be encoded.
  :param order_by_freq: boolean, whether the result StringIndex will assign smaller indices
         to values with more frequencies. Default is False and in this case frequency order
         may not be preserved when assigning indices.
  :param do_split: bool, whether need to split column value to array to encode string.
         Default is False.
  :param sep: str, a string representing a regular expression to split a column value.
         Default is ','.
  :param sort_for_array: bool, whether need to sort array columns. Default is False.
  :param keep_most_frequent: bool, whether need to keep most frequent value as the
         column value. Default is False.
  :param broadcast: bool, whether need to broadcast index when encode string.
         Default is True.
  
  :return: A tuple of a new FeatureTable which transforms categorical features into unique
           integer values, and a list of StringIndex for the mapping.
docstr_tok: ["Category","encode","the","given","columns",".",":","param","df",":","a","pyspark.sql.dataframe.DataFrame","to","be","processed",".",":","param","columns",":","str","or","a","list","of","str",",","target","columns","to","encode","from","string","to","index",".",":","param","freq_limit",":","int",",","dict","or","None",".","Categories","with","a","count\/frequency","below","freq_limit","will","be","omitted","from","the","encoding",".","Can","be","represented","as","either","an","integer",",","dict",".","For","instance",",","15",",","{","'col_4","'",":","10",",","'col_5","'",":","2","}","etc",".","Default","is","None",",","and","in","this","case","all","the","categories","that","appear","will","be","encoded",".",":","param","order_by_freq",":","boolean",",","whether","the","result","StringIndex","will","assign","smaller","indices","to","values","with","more","frequencies",".","Default","is","False","and","in","this","case","frequency","order","may","not","be","preserved","when","assigning","indices",".",":","param","do_split",":","bool",",","whether","need","to","split","column","value","to","array","to","encode","string",".","Default","is","False",".",":","param","sep",":","str",",","a","string","representing","a","regular","expression","to","split","a","column","value",".","Default","is","'",",","'",".",":","param","sort_for_array",":","bool",",","whether","need","to","sort","array","columns",".","Default","is","False",".",":","param","keep_most_frequent",":","bool",",","whether","need","to","keep","most","frequent","value","as","the","column","value",".","Default","is","False",".",":","param","broadcast",":","bool",",","whether","need","to","broadcast","index","when","encode","string",".","Default","is","True",".",":","return",":","A","tuple","of","a","new","FeatureTable","which","transforms","categorical","features","into","unique","integer","values",",","and","a","list","of","StringIndex","for","the","mapping","."]
code: def category_encode(
      self,
      df: "SparkDataFrame",
      columns: Union[str, List[str]],
      freq_limit: Optional[Union[int, Dict[str, int]]] = None,
      order_by_freq: bool = False,
      do_split: bool = False,
      sep: str = ",",
      sort_for_array: bool = False,
      keep_most_frequent: bool = False,
      broadcast: bool = True,
  ) -> Tuple[
      "SparkDataFrame", Union["StringIndex", List["StringIndex"]]
  ]:
      """
      Category encode the given columns.
  
      :param df: a pyspark.sql.dataframe.DataFrame to be processed.
      :param columns: str or a list of str, target columns to encode from string to index.
      :param freq_limit: int, dict or None. Categories with a count/frequency below freq_limit
             will be omitted from the encoding. Can be represented as either an integer,
             dict. For instance, 15, {'col_4': 10, 'col_5': 2} etc. Default is None,
             and in this case all the categories that appear will be encoded.
      :param order_by_freq: boolean, whether the result StringIndex will assign smaller indices
             to values with more frequencies. Default is False and in this case frequency order
             may not be preserved when assigning indices.
      :param do_split: bool, whether need to split column value to array to encode string.
             Default is False.
      :param sep: str, a string representing a regular expression to split a column value.
             Default is ','.
      :param sort_for_array: bool, whether need to sort array columns. Default is False.
      :param keep_most_frequent: bool, whether need to keep most frequent value as the
             column value. Default is False.
      :param broadcast: bool, whether need to broadcast index when encode string.
             Default is True.
  
      :return: A tuple of a new FeatureTable which transforms categorical features into unique
               integer values, and a list of StringIndex for the mapping.
      """
      indices = self.gen_string_idx(
          df,
          columns,
          freq_limit=freq_limit,
          order_by_freq=order_by_freq,
          do_split=do_split,
          sep=sep,
      )
      return (
          self.encode_string(
              df,
              columns,
              indices,
              do_split=do_split,
              sep=sep,
              sort_for_array=sort_for_array,
              keep_most_frequent=keep_most_frequent,
              broadcast=broadcast,
          ),
          indices,
      )
  
imports: import pyspark.sql.functions
  from pyspark.sql import Row
  from pyspark.sql.types import IntegerType, StructType, StringType, StructField
  from bigdl.dllib.utils.log4Error import invalidInputError
  from bigdl.orca.data import SparkXShards
  from bigdl.orca import OrcaContext
  from pyspark.ml.feature import MinMaxScaler
  from pyspark.ml.feature import StandardScaler
  from pyspark.ml.feature import VectorAssembler
  from pyspark.ml import Pipeline
  from bigdl.orca.data.utils import *
  import uuid
  from typing import TYPE_CHECKING, Tuple, Union, List
label_desc: Use image node_id 6 for calling the StringIndexer obj's underlying member method code with example usage: obj.category_encode(df, columns, freq_limit, order_by_freq, do_split, sep, sort_for_array, keep_most_frequent, broadcast) and returns: self,  indices