Skip to content

Random Functions

Functions for generating random values and sampling.

random

rand

rand() -> Func

Returns the random integer value.

Returns:

  • Func ( Func ) –

    A Func object that represents the rand function.

Example
dc.mutate(
    rnd=func.random.rand(),
)
Note
  • The result column will always be of type integer.
Source code in datachain/func/random.py
def rand() -> Func:
    """
    Returns the random integer value.

    Returns:
        Func: A `Func` object that represents the rand function.

    Example:
        ```py
        dc.mutate(
            rnd=func.random.rand(),
        )
        ```

    Note:
        - The result column will always be of type integer.
    """
    return Func("rand", inner=random.rand, result_type=int)