bigframes.bigquery.approx_top_count#
- bigframes.bigquery.approx_top_count(series: Series, number: int) Series[source]#
Returns the approximate top elements of expression as an array of STRUCTs. The number parameter specifies the number of elements returned.
Each STRUCT contains two fields. The first field (named value) contains an input value. The second field (named count) contains an INT64 specifying the number of times the value was returned.
Returns NULL if there are zero input rows.
Examples:
>>> import bigframes.pandas as bpd >>> import bigframes.bigquery as bbq >>> s = bpd.Series(["apple", "apple", "pear", "pear", "pear", "banana"]) >>> bbq.approx_top_count(s, number=2) [{'value': 'pear', 'count': 3}, {'value': 'apple', 'count': 2}]
- Parameters:
series (bigframes.series.Series) – The Series with any data type that the GROUP BY clause supports.
number (int) – An integer specifying the number of times the value was returned.
- Returns:
A new Series with the result data.
- Return type: