Skip to Content

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_df on the workflow context. Required columns: booking_date, check_in_date, check_out_date, and status. Optional: cancellation_date.

Outputs

  • Writes back an updated res_df with additional columns: cancellation_window (when cancellation date exists), booking_window (days between booking and check-in for future or completed reservations), and stay_nights (difference between check_out_date and check_in_date for future or completed reservations).

Behaviour and notes

  • Cancellation window is only calculated when cancellation_date exists on the row. The implementation computes an absolute datediff between check_in_date and cancellation_date.
  • Booking window and stay nights are calculated when the check_in_date is in the future or the reservation status is one of checked_in or checked_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 when guards to avoid incorrect values for past or ineligible reservations.
  • Ensure status values 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