DataFrame.nunique

DataFrame.nunique() Series

Return cardinality of each field.

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

This method will try and field aggregatable fields if possible if mapping has:

"customer_first_name" : {
  "type" : "text",
  "fields" : {
    "keyword" : {
      "type" : "keyword",
      "ignore_above" : 256
    }
  }
}

we will aggregate customer_first_name columns using customer_first_name.keyword.

TODO - implement remainder of pandas arguments

Returns

pandas.Series

cardinality of each column

See Also

:pandas_api_docs:`pandas.DataFrame.nunique`

Examples

>>> from tests import OPENSEARCH_TEST_CLIENT
>>> columns = ['category', 'currency', 'customer_birth_date', 'customer_first_name', 'user']
>>> df = oml.DataFrame(OPENSEARCH_TEST_CLIENT, 'ecommerce', columns=columns)
>>> df.nunique()
category                6
currency                1
customer_birth_date     0
customer_first_name    46
user                   46
dtype: int64