Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

time_shift: 관측 시각 이동

foundryts.functions.time_shift(duration)는 시계열 하나의 모든 시각에 duration을 더하는 함수를 반환합니다. (timestamp, value)는 (timestamp + duration, value)가 되며 관측값은 유지됩니다.

양수 duration은 시각을 늦추고 음수 duration은 시각을 앞당깁니다. 입력과 출력은 FunctionNode이며 숫자형과 범주형 값을 모두 유지할 수 있습니다.

duration 형식

형식해석
int나노초 단위 이동량
datetime.timedeltaPython 시간 간격
strpandas.Timedelta로 해석할 시간 간격. 예: 1 day, 1 hour, 10 minutes, 42s

1,000나노초 이동

import foundryts.functions as F

series = F.points(
    (100, 0.0),
    (200, float("inf")),
    (300, 3.14159),
    (2147483647, 1.0),
    name="series",
)
time_shifted = F.time_shift(1000)(series)
shifted_df = time_shifted.to_pandas()

가상 입력의 시각을 1,000나노초 늦춘 결과입니다.

입력 시각(ns)출력 timestampvalue
1001970-01-01 00:00:00.0000011000.0
2001970-01-01 00:00:00.000001200inf
3001970-01-01 00:00:00.0000013003.14159
21474836471970-01-01 00:00:02.1474846471.0

DataFrame의 timestamp는 pandas.Timestamp이며 value는 float 또는 str입니다. 값 자체에 이동량을 더하려면 value_shift를 사용합니다. 시각 단위를 맞추기 위한 timestamp_scale은 현재 입력을 변경하지 않습니다.