class_docstr: Aggregation request which can be passed to `Client.aggregate`.
class_docstr_tok: ["Aggregation","request","which","can","be","passed","to","`","Client.aggregate","`","."]
docstr: Specify by which fields to group the aggregation.
  
  ### Parameters
  
  - **fields**: Fields to group by. This can either be a single string,
      or a list of strings. both cases, the field should be specified as
      `@field`.
  - **reducers**: One or more reducers. Reducers may be found in the
      `aggregation` module.
docstr_tok: ["Specify","by","which","fields","to","group","the","aggregation",".","#","#","#","Parameters","-","*","*","fields","*","*",":","Fields","to","group","by",".","This","can","either","be","a","single","string",",","or","a","list","of","strings",".","both","cases",",","the","field","should","be","specified","as","`","@","field","`",".","-","*","*","reducers","*","*",":","One","or","more","reducers",".","Reducers","may","be","found","in","the","`","aggregation","`","module","."]
code: def group_by(
      self, fields: List[str], *reducers: Union[Reducer, List[Reducer]]
  ) -> "AggregateRequest":
      """
      Specify by which fields to group the aggregation.
  
      ### Parameters
  
      - **fields**: Fields to group by. This can either be a single string,
          or a list of strings. both cases, the field should be specified as
          `@field`.
      - **reducers**: One or more reducers. Reducers may be found in the
          `aggregation` module.
      """
      fields = [fields] if isinstance(fields, str) else fields
      reducers = (
          [reducers] if isinstance(reducers, Reducer) else reducers
      )
  
      ret = ["GROUPBY", str(len(fields)), *fields]
      for reducer in reducers:
          ret += ["REDUCE", reducer.NAME, str(len(reducer.args))]
          ret.extend(reducer.args)
          if reducer._alias is not None:
              ret += ["AS", reducer._alias]
  
      self._aggregateplan.extend(ret)
      return self
  
imports: from typing import List, Union
label_desc: Use image node_id 3 for calling the AggregateRequest obj's underlying member method code with example usage: obj.group_by(fields) and returns: self