cumulative_to_timeframe

passengersim.tracers.segmentation.cumulative_to_timeframe(df: DataFrame) → DataFrame[source]

Convert cumulative-through-DCP values into values within each timeframe.

Parameters:
df : pd.DataFrame

A table indexed with days_prior as its last level, holding cumulative values (from the start of the booking horizon through each DCP), such as the output of SegmentationTracer.finalize().

Returns:

pd.DataFrame – Same index levels, where each row’s days_prior labels the start of a timeframe, and values are the amounts booked from that DCP up to the next DCP (closer to departure). The final DCP (normally 0, departure) starts no timeframe and is dropped. This matches the convention used by SimTabSegmentationDetail.fig_segmentation_detail().