Skip to content
Project: Exploring Airbnb Market Trends
  • AI Chat
  • Code
  • Report
  • Welcome to New York City, one of the most-visited cities in the world. There are many Airbnb listings in New York City to meet the high demand for temporary lodging for travelers, which can be anywhere between a few nights to many months. In this project, we will take a closer look at the New York Airbnb market by combining data from multiple file types like .csv, .tsv, and .xlsx.

    Recall that CSV, TSV, and Excel files are three common formats for storing data. Three files containing data on 2019 Airbnb listings are available to you:

    data/airbnb_price.csv This is a CSV file containing data on Airbnb listing prices and locations.

    • listing_id: unique identifier of listing
    • price: nightly listing price in USD
    • nbhood_full: name of borough and neighborhood where listing is located

    data/airbnb_room_type.xlsx This is an Excel file containing data on Airbnb listing descriptions and room types.

    • listing_id: unique identifier of listing
    • description: listing description
    • room_type: Airbnb has three types of rooms: shared rooms, private rooms, and entire homes/apartments

    data/airbnb_last_review.tsv This is a TSV file containing data on Airbnb host names and review dates.

    • listing_id: unique identifier of listing
    • host_name: name of listing host
    • last_review: date when the listing was last reviewed
    # Importing packages
    import numpy as np
    import pandas as pd
    
    # Importing data
    last_review_filename = "data/airbnb_last_review.tsv"
    review_data = pd.read_csv(last_review_filename, sep='\t')
    
    room_type_filename = "data/airbnb_room_type.xlsx"
    room_type_data = pd.read_excel(room_type_filename)
    
    price_filename = "data/airbnb_price.csv"
    price_data = pd.read_csv(price_filename)
    # Turning the last_review column into datetime
    review_data["last_review"] = pd.to_datetime(review_data["last_review"], format ='%B %d %Y')
    # Finding the dates of earliest and most recent reviews
    earliest_review = review_data["last_review"].min()
    most_recent_review = review_data["last_review"].max()
    
    # Correcting typos for columns and finding how many of the listings are private rooms
    room_type_data["room_type"] = room_type_data["room_type"].str.lower()
    numbr_room_type = room_type_data["room_type"].value_counts()
    private_room = len(room_type_data[room_type_data["room_type"] == "private room"])
    
    # Removing dollars and changing the type of the price column of price data into int from object
    price_data["price"] = price_data["price"].str.replace(' dollars', '').astype('int32')
    # Finding the average listing price(rounded to nearest penny)
    avrg_price = np.round(price_data["price"].mean() * 100) / 100
    
    # Combining all findings into a DataFrame
    df = {'first_reviewed' : [earliest_review],
         'last_reviewed' : [most_recent_review],
         'nb_private_rooms' : [private_room],
         'avg_price' : [avrg_price]}
    review_dates = pd.DataFrame(df)
    print(review_dates)