Reservation Metrics
During this process it calculates the following metrics:
- Cancellation Window: Days between check-in and cancellation date (if cancellation date exists).
- Booking Window: Days between booking and check-in (for future or completed reservations).
- Stay Nights: Number of nights between check-in and check-out (for future or completed reservations).
Inputs
- Expects
res_dfon the workflow context. Required columns:booking_date,check_in_date,check_out_date, andstatus. Optional:cancellation_date.
Outputs
- Writes back an updated
res_dfwith additional columns:cancellation_window(when cancellation date exists),booking_window(days between booking and check-in for future or completed reservations), andstay_nights(difference betweencheck_out_dateandcheck_in_datefor future or completed reservations).
Behaviour and notes
- Cancellation window is only calculated when
cancellation_dateexists on the row. The implementation computes an absolute datediff betweencheck_in_dateandcancellation_date. - Booking window and stay nights are calculated when the
check_in_dateis in the future or the reservationstatusis one ofchecked_inorchecked_out. Otherwise those fields are set to null. - After computing metrics the runnable checkpoints the reservation DataFrame eagerly and writes it back to the workflow context.
Edge cases
- Missing or null dates will yield nulls in the computed columns. The code uses conditional
whenguards to avoid incorrect values for past or ineligible reservations. - Ensure
statusvalues used by the code (checked_in,checked_out) align with your source system semantics; otherwise booking window and stay night computations may be omitted.
Last updated on