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
    # We've loaded your first package for you! You can add as many cells as you need.
    import numpy as np
    import pandas as pd
    # Import the files needed
    last_review = pd.read_csv("./data/airbnb_last_review.tsv", sep = "\t")
    price = pd.read_csv("./data/airbnb_price.csv")
    room_type = pd.read_excel('./data/airbnb_room_type.xlsx')
    last_review.dtypes
    price.dtypes
    room_type["description"].unique()
    # Convert the last_review column to datetime
    last_review['last_review'] = pd.to_datetime(last_review['last_review'])
    
    # Find the earliest and most recent reviews
    earliest_review = last_review['last_review'].min().date()
    most_recent_review = last_review['last_review'].max().date()
    earliest_review
    # Convert 'private room', 'Private room', 'PRIVATE ROOM' to 'Private Bathroom'
    room_type['room_type'] = room_type['room_type'].str.lower().replace('private room', 'Private Room')
    # Count the number of private rooms
    private_rooms = len(room_type[room_type['room_type'] == 'Private Room'])
    private_rooms
    price
    # Calculate the average listing price
    price['price'] = price['price'].str.replace(' dollars', '').astype(float)
    avg_price = round(price['price'].mean(), 2)
    avg_price
    # Create the review_dates DataFrame
    review_dates = pd.DataFrame({
        'first_reviewed': [earliest_review],
        'last_reviewed': [most_recent_review],
        'nb_private_rooms': [private_rooms],
        'avg_price': [avg_price]
    })