rllm.preprocessing.TimestampPreprocessor

class rllm.preprocessing.TimestampPreprocessor(format: str | None = None, fields: Sequence[str] | None = None)[source]

Bases: object

Convert a timestamp column into structured time-component tensors. Parsed datetime values are decomposed into integer fields such as year, month, day, weekday, hour, minute, and second. By default all seven fields are returned with shape [N, 7], and missing or unparseable values are encoded as -1.

static to_tensor(ser: Series, fields: Sequence[str] | None = None) Tensor[source]

Convert a datetime64 Series to a long tensor.

Parameters:
  • ser – Series with dtype=datetime64[ns].

  • fields – Ordered list of field names to extract. Defaults to None which extracts all seven fields.

Returns:

Tensor of shape [N, len(fields)] with dtype=torch.long. Missing values are encoded as -1.