pandagg.response module

class pandagg.response.Aggregations(data: 'AggregationsResponseDict', _search: 'Search')[source]

Bases: object

keys() → List[str][source]
parse_group_by(*, response: Dict[str, Union[pandagg.types.BucketsWrapperDict, Dict[str, Any]]], until: Optional[str], with_single_bucket_groups: bool = False, row_as_tuple: bool = False) → Tuple[List[str], Union[List[Tuple[Tuple[Union[None, str, float], ...], Dict[str, Any]]], List[Tuple[Dict[str, Union[str, float, None]], Dict[str, Any]]]]][source]
to_dataframe(grouped_by: Optional[str] = None, normalize_children: bool = True, with_single_bucket_groups: bool = False) → pd.DataFrame[source]
to_normalized() → pandagg.response.NormalizedBucketDict[source]
to_tabular(*, index_orient: bool = True, grouped_by: Optional[str] = None, expand_columns: bool = True, expand_sep: str = '|', normalize: bool = True, with_single_bucket_groups: bool = False) → Tuple[List[str], Union[Dict[Tuple[Union[None, str, float], ...], Dict[str, Any]], List[Dict[str, Any]]]][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 dictionary
  • grouped_by – name of the aggregation node used as last grouping level
  • normalize – if True, normalize columns buckets
Returns:

index_names, values

class pandagg.response.Hit(data: 'HitDict', _document_class: 'Optional[DocumentMeta]')[source]

Bases: object

class pandagg.response.Hits(data: 'Optional[HitsDict]', _document_class: 'Optional[DocumentMeta]')[source]

Bases: object

hits
max_score
to_dataframe(expand_source: bool = True, source_only: bool = True) → pd.DataFrame[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)

total
class pandagg.response.NormalizedBucketDict[source]

Bases: dict

class pandagg.response.SearchResponse(data: 'SearchResponseDict', _search: 'Search')[source]

Bases: object

aggregations
hits
profile
success
timed_out
took