Skip to content
New Workbook
Sign up
Project: Exploring Airbnb Market Trends

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

Setup

# Loading necessary packages
import numpy as np
import pandas as pd
# Loading csv and tsv files
price = pd.read_csv('data/airbnb_price.csv')
review = pd.read_csv('data/airbnb_last_review.tsv', sep='\t')
# Loading xlsx file
xlsx_file = pd.ExcelFile('data/airbnb_room_type.xlsx')
sheet_names = xlsx_file.sheet_names
print("Sheet names:", sheet_names)
room_type = pd.read_excel('data/airbnb_room_type.xlsx')
price.info()
review.info()
room_type.info()
# Merging all dataframes
airbnb_df = price.merge(review, on='listing_id').merge(room_type, on='listing_id')

# Doing some data transformation for optimization (memory usage: 1.5+ MB)
airbnb_df['listing_id'] = airbnb_df['listing_id'].astype('int32')
airbnb_df['price'] = airbnb_df['price'].str.replace(' dollars', '').astype('int32')
airbnb_df['last_review'] = pd.to_datetime(airbnb_df['last_review'], format='%B %d %Y')

airbnb_df['room_type'] = airbnb_df['room_type'].str.lower()
airbnb_df['room_type'] = airbnb_df['room_type'].astype('category')

## final memory usage: 1.2+ MB
airbnb_df.info()

Questions

# What are the dates of the earliest and most recent reviews? 
earliest_review = airbnb_df.last_review.min()
most_recent_review = airbnb_df.last_review.max()

earliest_review, most_recent_review
# How many of the listings are private rooms
private_room_count = airbnb_df[airbnb_df['room_type'] == 'private room'].shape[0]
private_room_count
# What is the average listing price? Round to the nearest penny and save into a variable
avg_price = airbnb_df.price.mean().round(2)
avg_price