Lucas Lee














Sign up
Hotel Booking Demand np
  • AI Chat
  • Code
  • Report
  • Beta
    Spinner

    Hotel Booking Demand

    This dataset consists of booking data from a city hotel and a resort hotel. It includes many details about the bookings, including room specifications, the length of stay, the time between the booking and the stay, whether the booking was canceled, and how the booking was made. The data was gathered between July 2015 and August 2017.

    Not sure where to begin? Scroll to the bottom to find challenges!

    import pandas as pd
    import numpy as np
    
    df =pd.read_csv("hotel_bookings_clean.csv")

    Data Dictionary

    Note: For binary variables: 1 = true and 0 = false.

    ColumnExplanation
    is_canceledBinary variable indicating whether a booking was canceled
    lead_timeNumber of days between booking date and arrival date
    arrival_date_week_number, arrival_date_day_of_month, arrival_date_monthWeek number, day date, and month number of arrival date
    stays_in_weekend_nights, stays_in_week_nightsNumber of weekend nights (Saturday and Sunday) and weeknights (Monday to Friday) the customer booked
    adults, children, babiesNumber of adults, children, babies booked for the stay
    is_repeated_guestBinary variable indicating whether the customer was a repeat guest
    previous_cancellationsNumber of prior bookings that were canceled by the customer
    previous_bookings_not_canceledNumber of prior bookings that were not canceled by the customer
    required_car_parking_spacesNumber of parking spaces requested by the customer
    total_of_special_requestsNumber of special requests made by the customer
    avg_daily_rateAverage daily rate, as defined by dividing the sum of all lodging transactions by the total number of staying nights
    booked_by_companyBinary variable indicating whether a company booked the booking
    booked_by_agentBinary variable indicating whether an agent booked the booking
    hotel_CityBinary variable indicating whether the booked hotel is a "City Hotel"
    hotel_ResortBinary variable indicating whether the booked hotel is a "Resort Hotel"
    meal_BBBinary variable indicating whether a bed & breakfast meal was booked
    meal_HBBinary variable indicating whether a half board meal was booked
    meal_FBBinary variable indicating whether a full board meal was booked
    meal_No_mealBinary variable indicating whether there was no meal package booked
    market_segment_Aviation, market_segment_Complementary, market_segment_Corporate, market_segment_Direct, market_segment_Groups, market_segment_Offline_TA_TO, market_segment_Online_TA, market_segment_UndefinedIndicates market segment designation with a value of 1. "TA"= travel agent, "TO"= tour operators
    distribution_channel_Corporate, distribution_channel_Direct, distribution_channel_GDS, distribution_channel_TA_TO, distribution_channel_UndefinedIndicates booking distribution channel with a value of 1. "TA"= travel agent, "TO"= tour operators, "GDS" = Global Distribution System
    reserved_room_type_A, reserved_room_type_B, reserved_room_type_C, reserved_room_type_D, reserved_room_type_E, reserved_room_type_F, reserved_room_type_G, reserved_room_type_H, reserved_room_type_LIndicates code of room type reserved with a value of 1. Code is presented instead of designation for anonymity reasons
    deposit_type_No_DepositBinary variable indicating whether a deposit was made
    deposit_type_Non_RefundBinary variable indicating whether a deposit was made in the value of the total stay cost
    deposit_type_RefundableBinary variable indicating whether a deposit was made with a value under the total stay cost
    customer_type_ContractBinary variable indicating whether the booking has an allotment or other type of contract associated to it
    customer_type_GroupBinary variable indicating whether the booking is associated to a group
    customer_type_TransientBinary variable indicating whether the booking is not part of a group or contract, and is not associated to other transient booking
    customer_type_Transient-PartyBinary variable indicating whether the booking is transient, but is associated to at least another transient booking

    Source and license of data.

    Citation: The data is originally from an article called Hotel booking demand datasets by Nuno Antonio, Ana de Almeida, and Luis Nunes. It was cleaned by Thomas Mock and Antoine Bichat for #TidyTuesday during the week of February 11th, 2020.

    Don't know where to start?

    Challenges are brief tasks designed to help you practice specific skills:

    • 🗺️ Explore: Which family sizes are associated with the highest cancellation rate?
    • 📊 Visualize: Create a plot that visualizes the cancellation rates of different times of the year.
    • 🔎 Analyze: Are bookings with longer lead times more likely to result in a cancellation?

    Scenarios are broader questions to help you develop an end-to-end project for your portfolio:

    A chain of hotels has just hired you as a data analyst. They have noticed that the cancellation rate has risen in the past few years. This often leads to rooms that are left unrented for multiple days at a time.

    Hotel management is interested in developing a model to predict the likelihood that a customer will cancel their reservation. If successful, this could be used to optimize their booking service and anticipate when cancellations will occur.

    You will need to prepare a report that is accessible to a broad audience. It should outline your motivation, steps, findings, and conclusions.

    arr = np.array(df.head(20))
    arr
    df
    grid = [["L","U","C","K"],
            ["F","F","A","J"],
            ["C","P","S","F"],
            ["L","D","J","J"]]
    arr = np.array(grid)
    arr
    np.where(arr)
    word = "LUCAS"
    arr[0, :] == "L"
    cond= [(arr == "L") | (arr == "S"),
          (np.isin(arr, [v for v in word]))
           ,~np.isin(arr, [v for v in word])]
    
    choice = [arr, np.char.lower(arr), "_"]
    
    np.select(cond, choice, "_")
    
    height = [0,1,0,2,1,0,1,3,2,1,2,1]
    arr = np.arange(len(height))
    arr = arr.reshape(-1,1)
    height = np.array(height).reshape(-1, 1)
    arr = np.c_[arr, height]
    arr
    np.diff(arr)
    cube =[[2,3,2],
           [4,0,5],
           [2,7,2]]
    ## 我的思路是 下底 上底很好算
    ## 分兩部分: 先算直觀的左表面機 與右邊表面機:也就是人視覺從旁邊看到的四邊
    
    ## 內側的表面機還在琢磨
    # 例如  1, 1, 1
    #      1,*0*,1
    #      1, 2, 1
    up_area, bot_area, left_area, right_area = 0,0,0,0
    m, n = len(cube), len(cube[0])
    
    up_area += (m*n)
    bot_area = up_area
    
    cube = np.array(cube)
    np.max(cube, axis=1).sum() * 2 + np.max(cube, axis=0).sum() * 2