MCPcopy Create free account
hub / github.com/Open-Quant/openquant / to_polars_event_frame

Function to_polars_event_frame

python/openquant/adapters.py:30–49  ·  view source on GitHub ↗
(
    starts: Sequence[str],
    ends: Sequence[str],
    probs: Sequence[float],
    sides: Sequence[float] | None = None,
    labels: Sequence[int] | None = None,
)

Source from the content-addressed store, hash-verified

28
29
30def to_polars_event_frame(
31 starts: Sequence[str],
32 ends: Sequence[str],
33 probs: Sequence[float],
34 sides: Sequence[float] | None = None,
35 labels: Sequence[int] | None = None,
36) -> pl.DataFrame:
37 _validate_equal_length("starts", starts, "ends", ends)
38 _validate_equal_length("starts", starts, "probs", probs)
39 data: dict[str, object] = {"start_ts": list(starts), "end_ts": list(ends), "prob": list(probs)}
40 if sides is not None:
41 _validate_equal_length("starts", starts, "sides", sides)
42 data["side"] = list(sides)
43 if labels is not None:
44 _validate_equal_length("starts", starts, "labels", labels)
45 data["label"] = list(labels)
46 return pl.DataFrame(data).with_columns(
47 pl.col("start_ts").str.strptime(pl.Datetime, strict=False),
48 pl.col("end_ts").str.strptime(pl.Datetime, strict=False),
49 )
50
51
52def to_polars_indicator_matrix(

Callers

nothing calls this directly

Calls 1

_validate_equal_lengthFunction · 0.85

Tested by

no test coverage detected