def _hash_bucket(df: pd.DataFrame, subset: Optional[Sequence[str]], num_buckets: int):
    '\n    Categorize each row of `df` based on the data in the columns `subset`\n    into `num_buckets` values. This is based on `pandas.util.hash_pandas_object`\n    '
    if (not subset):
        subset = df.columns
    hash_arr = pd.util.hash_pandas_object(df[subset], index=False)
    buckets = (hash_arr % num_buckets)
    available_bit_widths = np.array([8, 16, 32, 64])
    mask = (available_bit_widths > np.log2(num_buckets))
    bit_width = min(available_bit_widths[mask])
    return df.assign(**{_KTK_HASH_BUCKET: buckets.astype(f'uint{bit_width}')})
Categorize each row of `df` based on the data in the columns `subset`
into `num_buckets` values. This is based on `pandas.util.hash_pandas_object`
def _hash_bucket(df: pd.DataFrame, subset: Optional[Sequence[str]], num_buckets: int):
    '\n    Categorize each row of `df` based on the data in the columns `subset`\n    into `num_buckets` values. This is based on `pandas.util.hash_pandas_object`\n    '
    if (not subset):
        subset = df.columns
    hash_arr = pd.util.hash_pandas_object(df[subset], index=False)
    buckets = (hash_arr % num_buckets)
    available_bit_widths = np.array([8, 16, 32, 64])
    mask = (available_bit_widths > np.log2(num_buckets))
    bit_width = min(available_bit_widths[mask])
    return df.assign(**{_KTK_HASH_BUCKET: buckets.astype(f'uint{bit_width}')})