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
# 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 = pd.read_csv('data/airbnb_price.csv')
price
room_type = pd.read_excel('data/airbnb_room_type.xlsx')
room_type
last_review = pd.read_table('data/airbnb_last_review.tsv', parse_dates=['last_review'])
last_review
last_review.info()
last_review['last_review'] = last_review['last_review'].dt.date
last_review['last_review']
earlist_date = last_review['last_review'].min()
nearist_data = last_review['last_review'].max()
room_type['room_type'] = room_type['room_type'].str.lower()
private_room = (room_type['room_type']=='private room').sum()
private_room
price['price'] = price['price'].str.split(' ').str.get(0)
average_price = price['price'].astype('int').mean().round(2)
review_dates = pd.DataFrame({'first_reviewed':[earlist_date], 'last_reviewed': [nearist_data], 'nb_private_rooms': [private_room], 'avg_price':[average_price]})
review_dates