pandagg.tree.agg module¶
-
class
pandagg.tree.agg.
Agg
(from_=None, mapping=None, identifier=None, client=None, query=None, index_name=None)[source]¶ Bases:
pandagg.tree._tree.Tree
Tree combination of aggregation nodes.
Mapping declaration is optional, but doing so validates aggregation validity.
-
DEFAULT_OUTPUT
= 'dataframe'¶
-
add_node
(node, pid=None)[source]¶ If mapping is provided, nested and outnested are automatically applied.
-
agg
(arg, insert_below=None, **kwargs)[source]¶ Arrange passed aggregations in arg arguments “horizontally”.
Those will be placed under the insert_below aggregation clause id if provided, else under the deepest linear bucket aggregation if there is no ambiguity: OK: A──> B ─> C ─> arg KO: A──> B
└──> Carg argument accepts single occurrence or sequence of following formats: - string (for terms agg concise declaration) - regular Elasticsearch dict syntax - AggNode instance (for instance Terms, Filters etc)
Parameters: - arg – aggregation(s) clauses to insert “horizontally”
- insert_below – parent aggregation id under which these aggregations should be placed
- kwargs – agg body arguments when using “string” syntax for terms aggregation
Return type:
-
deepest_linear_bucket_agg
¶ Return deepest bucket aggregation node (pandagg.nodes.abstract.BucketAggNode) of that aggregation that neither has siblings, nor has an ancestor with siblings.
-
groupby
(by, insert_below=None, insert_above=None, **kwargs)[source]¶ Arrange passed aggregations in by arguments “vertically” (nested manner), above or below another agg clause.
Given the initial aggregation: A──> B └──> C
If insert_below = ‘A’: A──> by──> B
└──> CIf insert_above = ‘B’: A──> by──> B └──> C
by argument accepts single occurrence or sequence of following formats: - string (for terms agg concise declaration) - regular Elasticsearch dict syntax - AggNode instance (for instance Terms, Filters etc)
If insert_below nor insert_above is provided by will be placed between the the deepest linear bucket aggregation if there is no ambiguity, and its children: A──> B : OK generates A──> B ─> C ─> by
A──> B : KO, ambiguous, must precise either A, B or C └──> C
Parameters: - by – aggregation(s) clauses to insert “vertically”
- insert_below – parent aggregation id under which these aggregations should be placed
- insert_above – aggregation id above which these aggregations should be placed
- kwargs – agg body arguments when using “string” syntax for terms aggregation
Return type:
-
node_class
¶ alias of
pandagg.node.agg.abstract.AggNode
-