qis.utils.quantile_buckets.classify_quantile_buckets¶
- qis.utils.quantile_buckets.classify_quantile_buckets(x, q, labels=None, is_require_occupied=True)[source]¶
Quantile bucket of each observation as an ordered categorical.
- Parameters:
x (ndarray | Series) – observations; a Series keeps its index and name
q (int | Sequence[float] | ndarray) – the partition, see
get_quantile_probabilitieslabels (Sequence[str] | None) – one label per bucket, lowest first; None uses the bucket numbers 0 to k - 1
is_require_occupied (bool) – raise when a bucket holds no observation
- Returns:
the ordered categorical buckets, every label a category even when unobserved, missing for a NaN or infinite observation
- Raises:
ValueError – if the number of labels is not the number of buckets
EmptyQuantileBucketError – if
is_require_occupiedand a bucket is empty
- Return type: