pandagg.response module

class pandagg.response.Aggregations(data, search)[source]

Bases: object

get(key)[source]
keys()[source]
serialize(output='tabular', **kwargs)[source]
Parameters:
  • output – output format, one of “raw”, “tree”, “interactive_tree”, “normalized”, “tabular”, “dataframe”
  • kwargs – tabular serialization kwargs
Returns:

to_dataframe(grouped_by=None, normalize_children=True, with_single_bucket_groups=False)[source]
to_interactive_tree()[source]
to_normalized()[source]
to_tabular(index_orient=True, grouped_by=None, expand_columns=True, expand_sep='|', normalize=True, with_single_bucket_groups=False)[source]

Build tabular view of ES response grouping levels (rows) until ‘grouped_by’ aggregation node included is reached, and using children aggregations of grouping level as values for each of generated groups (columns).

Suppose an aggregation of this shape (A & B bucket aggregations):

A──> B──> C1
     ├──> C2
     └──> C3

With grouped_by=’B’, breakdown ElasticSearch response (tree structure), into a tabular structure of this shape:

                      C1     C2    C3
A           B
wood        blue      10     4     0
            red       7      5     2
steel       blue      1      9     0
            red       23     4     2
Parameters:
  • index_orient – if True, level-key samples are returned as tuples, else in a dictionnary
  • grouped_by – name of the aggregation node used as last grouping level
  • normalize – if True, normalize columns buckets
Returns:

index_names, values

to_tree()[source]
class pandagg.response.Hit(data)[source]

Bases: object

class pandagg.response.Hits(hits)[source]

Bases: object

to_dataframe(expand_source=True, source_only=True)[source]

Return hits as pandas dataframe. Requires pandas dependency. :param expand_source: if True, _source sub-fields are expanded as columns :param source_only: if True, doesn’t include hit metadata (except id which is used as dataframe index)

class pandagg.response.Response(data, search)[source]

Bases: object

success