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
    
    
    # Begin coding here ...
    price_df = pd.read_csv('data/airbnb_price.csv')
    room_type_df = pd.read_excel('data/airbnb_room_type.xlsx')
    review_df = pd.read_csv('data/airbnb_last_review.tsv', delimiter = '\t')
    price_df.info()
    room_type_df.info()
    review_df.info()
    main_df = pd.merge(price_df, room_type_df, on = 'listing_id', how = 'inner')
    main_df = pd.merge(main_df, review_df, on = 'listing_id', how = 'inner')
    
    main_df.head()
    # Display the information about the main DataFrame
    main_df.shape
    main_df['last_review_date'] = pd.to_datetime(main_df['last_review'], format = '%B %d %Y')
    oldest_review = main_df['last_review_date'].min()
    newest_review = main_df['last_review_date'].max()
    private_room = main_df[main_df['room_type'].str.lower() == 'private room'].shape[0]
    avg_price = main_df['price'].str.replace(' dollars', '').astype(int).mean().round(2)
    dict = {
        'first_reviewed' : [oldest_review],
        'last_reviewed' : [newest_review],
        'nb_private_rooms' : [private_room],
        'avg_price' : [avg_price]
    }
    
    
    review_dates = pd.DataFrame(dict)
    review_dates