Series.value_counts

Series.value_counts(os_size: int = 10) Series[source]

Return the value counts for the specified field.

Note we can only do this for aggregatable OpenSearch fields - (in general) numeric and keyword rather than text fields

TODO - implement remainder of pandas arguments

Parameters

os_size: int, default 10

Number of buckets to return counts for, automatically sorts by count descending. This parameter is specific to opensearch_py_ml, and determines how many term buckets OpenSearch should return out of the overall terms list.

Returns

pandas.Series

number of occurrences of each value in the column

See Also

:pandas_api_docs:`pandas.Series.value_counts` :os_api_docs:`search-aggregations-bucket-terms-aggregation`

Examples

>>> from tests import OPENSEARCH_TEST_CLIENT
>>> df = oml.DataFrame(OPENSEARCH_TEST_CLIENT, 'flights')
>>> for key, value in df['Carrier'].value_counts().items():
...     print(key, value)
Logstash Airways 3331
JetBeats 3274
Kibana Airlines 3234
ES-Air 3220