otp.Source.ranking#

Source.ranking(bucket_interval=0, bucket_units='seconds', bucket_time='end', bucket_end_condition=None, boundary_tick_bucket='new', group_by=None, end_condition_per_group=False)[source]#

Ranking running aggregation.

Sorts a series of ticks over a bucket interval using a specified set of tick fields specified in rank_by and adds a new field RANKING with the position of the tick in the sort order or the percentage of ticks with values less than (or equal) to the value of the tick.

Does not change the order of the ticks.

Parameters
  • rank_by (str or list or dict) – Set of fields to sort by. Can be one field specified by string, list of fields or dictionary with field names as keys and asc or desc string literals as values. Latter allows to specify sorting direction. Default direction is desc.

  • show_rank_as (str) –

    • order: calculate number that represents the position of the tick in the sort order

    • percent_le_values: calculate the percentage of ticks that have higher or equal value of the position in the sort order, relative to the tick

    • percent_lt_values: calculate the percentage of ticks that have higher value of the position in the sort order, relative to the tick

    • percentile_standard: calculate Percentile Rank of the tick in the sort order.

  • include_tick (bool, default=False) – Specifies whether the current tick should be included in calculations if show_rank_as is percent_lt_values or percentile_standard.

  • bucket_interval (int) – Determines the length of each bucket (units depends on bucket_units).

  • bucket_units (Literal['seconds', 'ticks', 'days', 'months', 'flexible']) –

    Set bucket interval units.

    If set to flexible bucket_end_criteria must be set.

  • bucket_time (Literal['start', 'end']) –

    Control output timestamp.

    • start

      the timestamp assigned to the bucket is the start time of the bucket.

    • end

      the timestamp assigned to the bucket is the end time of the bucket.

  • bucket_end_condition (condition) – An expression that is evaluated on every tick. If it evaluates to “True”, then a new bucket is created. This parameter is only used if bucket_units is set to “flexible”

  • boundary_tick_bucket (Literal['new', 'previous']) –

    Controls boundary tick ownership.

    • previous

      A tick on which bucket_end_condition evaluates to “true” belongs to the bucket being closed.

    • new

      tick belongs to the new bucket.

    This parameter is only used if bucket_units is set to “flexible”

  • group_by (list, str or expression) – When specified, each bucket is broken further into additional sub-buckets based on specified field values.

  • end_condition_per_group (bool) –

    Controls application of bucket_end_condition in groups.

    • end_condition_per_group = True

      bucket_end_condition is applied only to the group defined by group_by

    • end_condition_per_group = False

      bucket_end_condition applied across all groups

    This parameter is only used if bucket_units is set to “flexible”

Return type

Source

See also

RANKING OneTick event processor