<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/transform/blob/v1.21.0/tensorflow_transform/mappers.py#L2299-L2354) |

Returns a bucketized column, with a bucket index assigned to each input.

    tft.apply_buckets(
        x: common_types.ConsistentTensorType,
        bucket_boundaries: common_types.BucketBoundariesType,
        name: Optional[str] = None
    ) -> common_types.ConsistentTensorType

Each element `e` in `x` is mapped to a positive index `i` for which
`bucket_boundaries[i-1] <= e < bucket_boundaries[i]`, if it exists.
If `e < bucket_boundaries[0]`, then `e` is mapped to `0`. If
`e >= bucket_boundaries[-1]`, then `e` is mapped to `len(bucket_boundaries)`.
NaNs are mapped to `len(bucket_boundaries)`.

#### Example:

*** ** * ** ***

    >>> x = tf.constant([[4.0, float('nan'), 1.0], [float('-inf'), 7.5, 10.0]])
    >>> bucket_boundaries = tf.constant([[2.0, 5.0, 10.0]])
    >>> tft.apply_buckets(x, bucket_boundaries)
    <tf.Tensor: shape=(2, 3), dtype=int64, numpy=
    array([[1, 3, 0],
           [0, 2, 3]])>

<br />

<br />

<br />

| ## Args ||
|---|---|

<br />

*** ** * ** ***

x: A numeric input `Tensor`, `SparseTensor`, or `RaggedTensor` whose values
should be mapped to buckets. For `CompositeTensor`s, the non-missing
values will be mapped to buckets and missing value left missing.
bucket_boundaries: A rank 2 `Tensor` or list representing the bucket
boundaries sorted in ascending order.
name: (Optional) A name for this operation.

<br />

<br />

<br />

| ## Returns ||
|---|---|

<br />

*** ** * ** ***

A `Tensor`, `SparseTensor`, or `RaggedTensor` of the same shape as `x`, with
each element in the returned tensor representing the bucketized value.
Bucketized value is in the range \[0, len(bucket_boundaries)\].