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 listingprice
: nightly listing price in USDnbhood_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 listingdescription
: listing descriptionroom_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 listinghost_name
: name of listing hostlast_review
: date when the listing was last reviewed
# Import necessary packages
import pandas as pd
import numpy as np
import missingno as msno
import matplotlib.pyplot as plt
# Begin coding here ...
# Use as many cells as you like
airbnb_price = pd.read_csv('data/airbnb_price.csv')
airbnb_room_type = pd.read_excel('data/airbnb_room_type.xlsx')
airbnb_last_review = pd.read_csv('data/airbnb_last_review.tsv', sep='\t')
airbnb_price.head()
airbnb_room_type.head()
airbnb_last_review.head()
airbnb_price.info()
airbnb_room_type.info()
airbnb_last_review.info()
combined_airbnb = pd.merge(airbnb_price, airbnb_room_type, on='listing_id')
combined_airbnb = pd.merge(combined_airbnb, airbnb_last_review, on='listing_id')
combined_airbnb.head()
combined_airbnb.info()
combined_airbnb.isna().sum()
combined_airbnb[combined_airbnb['host_name'].isna()]
combined_airbnb[combined_airbnb['description'].isna()]
# missing_values = combined_airbnb[['host_name', 'description']].isna().any(axis=1)
# combined_airbnb = combined_airbnb.dropna(subset=['host_name', 'description'])
# combined_airbnb.isna().sum()
combined_airbnb['price'] = combined_airbnb['price'].str.extract('(\d+)').astype(int)
# combined_airbnb['price'] = combined_airbnb['price'].str.replace(' dollars', '').astype(int)
combined_airbnb.info()
combined_airbnb.head()