class_docstr: Builds DP queries on (Spark, Pandas, Beam) DataFrames.
  
  It uses a Builder pattern, each public function except of build_query
  returns the reference to itself.
  The usage is
  QueryBuilder().groupby(...).aggregation1(...)....aggregation_n().build_query()
  
  Example:
      # The following query computes restaurant visits and total money
      # spent:
      query = QueryBuilder(df, "user_id")
      .groupby("day", max_groups_contributed=3, max_contributions_per_group=1)
      .count()
      .sum("spent_money", min_value=0, max_value=100)
      .mean("spent_money") # no need to specify min_value, max_value, they
      # were already given in sum
      .build_query()
class_docstr_tok: ["Builds","DP","queries","on","(","Spark",",","Pandas",",","Beam",")","DataFrames",".","It","uses","a","Builder","pattern",",","each","public","function","except","of","build_query","returns","the","reference","to","itself",".","The","usage","is","QueryBuilder","(",")",".groupby","(","...",")",".aggregation1","(","...",")","....","aggregation_n","(",")",".build_query","(",")","Example",":","#","The","following","query","computes","restaurant","visits","and","total","money","#","spent",":","query","=","QueryBuilder","(","df",",","``","user_id","''",")",".groupby","(","``","day","''",",","max_groups_contributed=3",",","max_contributions_per_group=1",")",".count","(",")",".sum","(","``","spent_money","''",",","min_value=0",",","max_value=100",")",".mean","(","``","spent_money","''",")","#","no","need","to","specify","min_value",",","max_value",",","they","#","were","already","given","in","sum",".build_query","(",")"]
docstr: Adds groupby by the given column to the query.
  
  All following aggregation will be applied to grouped by DataFrame.
  
  Note:  If 'public_keys' are provided, then the keys of the output
    DataFrame keys  will exactly coincide with provided 'public_keys'.
    If some public key is missing in the input DataFrame the output
    DataFrame will still a value, to ensure DP. For example in case if
    COUNT, the value will be 0 + noise.
  
  Args:
      by: a column or a list of columns used to determine the groups.
      max_groups_contributed: the maximum groups that can each privacy
        unit contributes to the result. If some privacy unit contributes
        more in the input dataset, the groups are sub-sampled to
        max_groups_contributed.
      max_contributions_per_group: the maximum contribution that a privacy
        unit can contribute to a group. If some privacy unit contributes
        more to some group, contributions are sub-sampled to
        max_contributions_per_group.
      public_keys: the list of groupby keys which are known before the
        running aggregations. It can be for example dates, countries etc.
        If not provided, keys will be selected in a DP manner.
docstr_tok: ["Adds","groupby","by","the","given","column","to","the","query",".","All","following","aggregation","will","be","applied","to","grouped","by","DataFrame",".","Note",":","If","'public_keys","'","are","provided",",","then","the","keys","of","the","output","DataFrame","keys","will","exactly","coincide","with","provided","'public_keys","'",".","If","some","public","key","is","missing","in","the","input","DataFrame","the","output","DataFrame","will","still","a","value",",","to","ensure","DP",".","For","example","in","case","if","COUNT",",","the","value","will","be","0","+","noise",".","Args",":","by",":","a","column","or","a","list","of","columns","used","to","determine","the","groups",".","max_groups_contributed",":","the","maximum","groups","that","can","each","privacy","unit","contributes","to","the","result",".","If","some","privacy","unit","contributes","more","in","the","input","dataset",",","the","groups","are","sub-sampled","to","max_groups_contributed",".","max_contributions_per_group",":","the","maximum","contribution","that","a","privacy","unit","can","contribute","to","a","group",".","If","some","privacy","unit","contributes","more","to","some","group",",","contributions","are","sub-sampled","to","max_contributions_per_group",".","public_keys",":","the","list","of","groupby","keys","which","are","known","before","the","running","aggregations",".","It","can","be","for","example","dates",",","countries","etc",".","If","not","provided",",","keys","will","be","selected","in","a","DP","manner","."]
code: def groupby(
      self,
      by: Union[str, Sequence[str]],
      *,
      max_groups_contributed: int,
      max_contributions_per_group: int,
      public_keys: Optional[Iterable[Any]] = None,
      column: Optional[str] = None,  # deprecated
  ) -> "QueryBuilder":
      """Adds groupby by the given column to the query.
  
      All following aggregation will be applied to grouped by DataFrame.
  
      Note:  If 'public_keys' are provided, then the keys of the output
        DataFrame keys  will exactly coincide with provided 'public_keys'.
        If some public key is missing in the input DataFrame the output
        DataFrame will still a value, to ensure DP. For example in case if
        COUNT, the value will be 0 + noise.
  
      Args:
          by: a column or a list of columns used to determine the groups.
          max_groups_contributed: the maximum groups that can each privacy
            unit contributes to the result. If some privacy unit contributes
            more in the input dataset, the groups are sub-sampled to
            max_groups_contributed.
          max_contributions_per_group: the maximum contribution that a privacy
            unit can contribute to a group. If some privacy unit contributes
            more to some group, contributions are sub-sampled to
            max_contributions_per_group.
          public_keys: the list of groupby keys which are known before the
            running aggregations. It can be for example dates, countries etc.
            If not provided, keys will be selected in a DP manner.
      """
      if column is not None:
          raise ValueError("column argument is deprecated. Use by")
      if self._by is not None:
          raise ValueError("groupby can be called only once")
  
      if isinstance(by, str):
          if by not in self._df.columns:
              raise ValueError(
                  f"Column {by} is not present in DataFrame"
              )
      elif isinstance(by, list):
          # List of columns
          for column in by:
              if column not in self._df.columns:
                  raise ValueError(
                      f"Column {column} is not present in DataFrame"
                  )
      else:
          raise ValueError(f"by argument must be column name(s)")
      self._by = by
      self._max_partitions_contributed = max_groups_contributed
      self._max_contributions_per_partition = (
          max_contributions_per_group
      )
      self._public_keys = public_keys
      return self
  
imports: import abc
  import copy
  from collections import namedtuple
  from dataclasses import dataclass
  from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, Union
  import pipeline_dp
  import pyspark
label_desc: Use image node_id 2 for calling the QueryBuilder obj's underlying member method code with example usage: obj.groupby(by) and returns: self