time_field()function

Create a time column specification.

USAGE

time_field(
    min_time=None,
    max_time=None,
    nullable=False,
    null_probability=0.0,
    unique=False,
    generator=None,
)

Parameters

min_time : str | time | None = None

Minimum time (inclusive). Can be ISO string or time object.

max_time : str | time | None = None

Maximum time (inclusive). Can be ISO string or time object.

nullable : bool = False

Whether the column can contain null values. Default is False.

null_probability : float = 0.0

Probability of generating null when nullable=True. Default is 0.0.

unique : bool = False

Whether all values must be unique. Default is False.

generator : Callable[[], Any] | None = None

Custom callable that generates values. Overrides other settings.

Returns

TimeField

A time field specification.

Examples


Define a schema with time fields and generate test data:

import pointblank as pb
from datetime import time

# Define a schema with time field specifications
schema = pb.Schema(
    start_time=pb.time_field(
        min_time=time(9, 0, 0),
        max_time=time(12, 0, 0)
    ),
    end_time=pb.time_field(
        min_time=time(13, 0, 0),
        max_time=time(17, 0, 0)
    ),
)

# Generate 100 rows of test data
pb.preview(pb.generate_dataset(schema, n=100, seed=23))
PolarsRows100Columns2
start_time
String
end_time
String
1 10:19:09 16:32:49
2 09:22:48 14:19:09
3 09:04:39 16:46:32
4 11:41:39 13:22:48
5 10:23:45 13:04:39
96 10:53:39 15:29:54
97 10:47:25 13:59:36
98 09:06:22 14:10:33
99 09:44:23 13:40:49
100 10:01:36 13:29:15

Time values are uniformly distributed within the specified range.